-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_input.py
30 lines (24 loc) · 1.13 KB
/
user_input.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from datetime import date
import pandas as pd
import sys
#set today's month as the default end date to ensure the API call goes up to today
today_time = date.today().strftime("%Y-%m")
#import user transactions and convert to a dataframe
while True:
try:
print("Please submit your deposits/withdrawls in the following format:\nYYYY-MM XXXX\nYYYY-MM XXXX\nUse Ctril+d to submit your data without entering a blank line")
userdepositraw = sys.stdin.read().splitlines()
deposits = [x.split() for x in userdepositraw]
depositsdf = pd.DataFrame(deposits, columns = ['year_month','deposits'])
depositsdf['deposits']= depositsdf['deposits'].astype(int)
depositsdf['year_month'] = pd.to_datetime(depositsdf['year_month'])
netdepositsdf = depositsdf.groupby(['year_month']).sum().reset_index()
print()
print("Deposits submitted, thank you.")
break
except:
print("Input not accepted, please try again.")
#find the earliest date to query inflation data from
earliest_date = min(netdepositsdf['year_month'])
start_time =earliest_date.strftime("%Y-%m")
end_time =today_time