I tried various things, I calmed down like this.
for sp in set(data['element']):
df_op = data[data['element'] == sp]
com_plot(df_op,sp) #Move to the function to aggregate.
I had selected the file name,
import glob
print("Start reading transaction data")
csv_name = r"Folder with input data\*.csv"
csv_files = glob.glob(csv_name)
list = []
for f in csv_files:
list.append(pd.read_csv(f, index_col=0).drop(['Payment Number','Refund Number'], axis=1))
df = pd.concat(list)
Change the processing content by entering any of "YYMMDD", "YYMM", and "all".
def main():
print("Specify the aggregation date "YYMMDD" or "YYMM" or "all"")
print("Change the acquired contents in the format of the aggregated date")
day = input("Specify the aggregation date-> ")
print("")
if (len(day) == 6):
print("Date and time data aggregation")
df = day_data(day)
data_plot(df,day,True)
top_20(df,day)
elif (len(day) == 4):
df = o_mon_data(day)
data_plot(df,day,True)
top_20(df,day)
elif (day == all):
df = month_data()
data_plot(df,day,False)
else:
print("Redo")
main()
if __name__ == '__main__':
main()
def day_data(day):
print("Extract with this →:", day)
yy = day[:2]
mm = day[2:4]
Add TOTAL → sort → delete TOTAL In my environment, I get a little angry when deleting TOTAK rows and columns. .. ..
#Descending sort by TOTAL
data.sort_values(['TOTAL'],ascending=False,inplace=True)
#Swap the matrix using the top 20
pvtop20=data[:21]
#TOTAL row and column deletion
drop_idx = ['TOTAL']
pvtop20.drop(drop_idx, inplace=True)
drop_col = ['TOTAL']
pvtop20.drop(drop_col, axis=1, inplace=True)
Linked from data with the same key. I was supposed to use a dictionary, The function of pandas was amazing. .. ..
print(Daily data + alpha)
data = pd.merge(df, tenbun_meisai, on=["Key"])
Although csv aggregation in perl was the basis of the idea I was able to do what I wanted to do.
I forgot to write tkinter, so I added it
import os, tkinter, tkinter.filedialog, tkinter.messagebox
#Display file selection dialog
root = tkinter.Tk()
root.withdraw()
#I want to extract csv, so the extension is displayed as csv
fTyp = [("","*.csv")]
#Specify the folder where the input file exists
iDir = r'hoge'
#Input file selection
tkinter.messagebox.showinfo('Data extraction target selection','Select a processing file!')
file = tkinter.filedialog.askopenfilenames(filetypes = fTyp,initialdir = iDir)
list = []
for f in file:
list.append(pd.read_csv(f, index_col=0).drop(['Payment Number','Refund Number'], axis=1))
df = pd.concat(list)
Recommended Posts