i am new to coding and trying to apply what I've learned to my work.
I have 7 sales record(by month) files in csv format, which i read by pd.read_csv().
Below is an example of what each file looks like.
Account A | Account B | Account C | |
---|---|---|---|
product 1 | 1 | 2 | 3 |
product 2 | 1 | 2 | 3 |
product 3 | 1 | 2 | 3 |
product 4 | 1 | 2 | 3 |
What i am trying to achieve is to make separate dataframes for each product, with months as index and Account names as columns. Any suggestion on how can i perform this task?
Some people say that using list of list and appending data row by row is better than creating multiple empty data frames and appending data in them. so i created multiple lists for appending data in with the simple code below:
product_name = ['product 1', 'product 2', 'product 3', 'product 4']
for name in product_name:
name = []
What should be the next steps in drawing data from the original sales record file and how can i append them to the empty list?
Afterward, should i use the code below to transform each list into dataframe?
months = ['Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar']
account = ['Account A', 'Account B', 'Account C']
df = pd.DataFrame (name, columns = account, index = months)
And finally, may i know how can i save the final separated dataframes into separated files?
Thx!