I have Excel with 3 sheets: Gross, Margin, Revenue. Each of them has a table with same columns and row headers.
I need to :
1) iterate through each sheet and save into a dataframe
2) unpivot each dataframe
3) append value columns from each daraframe into one.
Gross:
Margin:
Revenue:
Outcome should be like this:
If I use sheet_name=None
then I get an error:
import pandas as pd
df = pd.read_excel('BudgetData.xlsx', sheet_name=None,index=False)
df_unpv = df.melt(id_vars=['Company'], var_name ='Month', value_name = 'Gross Revenue')
print(df_unpv)
Error I get:
AttributeError Traceback (most recent call last)
<ipython-input-60-ee1791c449b1> in <module>
1 import pandas as pd
2 df = pd.read_excel('BudgetData.xlsx', sheet_name=None,index=False)
----> 3 df_unpv = df.melt(id_vars=['Company'], var_name ='Month', value_name = 'Gross Revenue')
4 df_unpv
5
AttributeError: 'collections.OrderedDict' object has no attribute 'melt'
Excel file with sample data can be found here: https://www.dropbox.com/s/9dsnylng70t5a8i/Count%20Open%20and%20Closed%20at%20Point%20of%20time.pbix?dl=0