Created
January 3, 2018 21:00
-
-
Save dword4/11842fa4c588451e0da3977c9d5aad76 to your computer and use it in GitHub Desktop.
quick bit of python to figure out how much has been spent on any given thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import pandas as pd | |
import numpy as np | |
import sys | |
target = sys.argv[1] | |
def getTargetTotal(target): | |
df = pd.read_csv('data.csv', header=None,names=['date','description','ammount','balance']) | |
df.replace('(^\-\$)', '', regex=True, inplace=True) | |
Total = df.loc[df['description'].str.contains(target),'ammount'].sum() | |
df2 = pd.to_numeric(df.loc[df['description'].str.contains(target),'ammount']) | |
return df2.sum() | |
def getTargetCount(target): | |
df = pd.read_csv('data.csv', header=None,names=['date','description','ammount','balance']) | |
df.replace('(^\-\$)', '', regex=True, inplace=True) | |
Total = df.loc[df['description'].str.contains(target),'ammount'].sum() | |
df2 = pd.to_numeric(df.loc[df['description'].str.contains(target),'ammount']) | |
return df2.count() | |
print("Total:",getTargetTotal(target),"$") | |
print("Transactions:",getTargetCount(target)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment