Finparse
Parse financial strings to number objects
Installation
pip install finparse
Usage
import finparse
finparse.parse("$1,234,567.89")
# => 1234567.89
finparse.parse("€1.234.567,89", decimal=",")
# => 1234567.89
finparse.parse("($1,234,567.89)")
# => -1234567.89
import decimal
finparse.parse("$1,234,567.89", cast=decimal.Decimal)
# => Decimal('1234567.89')
Pandas
Pandas' read_csv() function provdides a converters argument that applies a function to the given column.
Using the example CSV file ./tests/example.csv, we can see the following behavior:
import pandas
df = pandas.read_csv('./tests/example.csv')
print(df)
# => Acct Balance
# 0 Savings $1,234.567
# 1 Checking ($0.987)
With the converters argument we can parse these values to floats:
import finparse
import pandas
df = pandas.read_csv('./tests/example.csv', converters={'Balance': finparse.parse})
print(df)
# => Acct Balance
# 0 Savings 1234.567
# 1 Checking -0.987
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
finparse-0.2.0.tar.gz
(4.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file finparse-0.2.0.tar.gz.
File metadata
- Download URL: finparse-0.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
468d4de18a20e0da972fd41baab8b995080fc60a1a935878a92bbcce13d6fe13
|
|
| MD5 |
49ee71fbd84bbebf6e5538deee4d6bfc
|
|
| BLAKE2b-256 |
200fa8e772da441c5a69a2f8efd80611cffce043b6e6edcc8644f29febf4f282
|
File details
Details for the file finparse-0.2.0-py3-none-any.whl.
File metadata
- Download URL: finparse-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211236becaa4538bc3238cbd905605739dcbf147f506aae3d230205bd31e2d3a
|
|
| MD5 |
b4556dcbdba1d725cd2e0b4f10c28900
|
|
| BLAKE2b-256 |
0c1c1b73a9b1d84b3de5164d4c9fae0780182dd24ec60f2afa279f026139d3f8
|