I'm trying to upload a df to google sheets using the df2gspread module. The data frames looks like this:
Org Name | TSTAcme | TSTExample | Total | ||||||
---|---|---|---|---|---|---|---|---|---|
Cost | Net Revenue | Revenue | Cost | Net Revenue | Revenue | Cost | Net Revenue | Revenue | |
Date | |||||||||
2023-01-03 | 6.49 | 26039.51 | 26046.00 | 0 | 0 | 0 | 6.49 | 26039.51 | 26046.00 |
2023-01-06 | 3.54 | 36778.46 | 36782.00 | 0 | 0 | 0 | 3.54 | 36778.46 | 36782.00 |
2023-01-09 | 4.13 | 29825.87 | 29830.00 | 0 | 0 | 0 | 4.13 | 29825.87 | 29830.00 |
2023-01-10 | 0.59 | 20094.41 | 20095.00 | 0 | 0 | 0 | 0.59 | 20094.41 | 20095.00 |
2023-01-11 | 0 | 0 | 0 | 1.12 | 38581.88 | 38583.00 | 1.12 | 38581.88 | 38583.00 |
2023-01-12 | 0 | 0 | 0 | 1.18 | 36127.82 | 36129.00 | 1.18 | 36127.82 | 36129.00 |
2023-01-17 | 0.00 | 28908.00 | 28908.00 | 0 | 0 | 0 | 0.00 | 28908.00 | 28908.00 |
Total | 14.75 | 141646.25 | 141661.00 | 2.30 | 74709.70 | 74712.00 | 17.05 | 216355.95 | 216373.00 |
The pandas to_excel function works fine and I'm able to export this to an excel file without any problems.
Setting a MultiIndex dtype to anything other than object is not supported
The above error comes up when I try to upload this to a google sheet using d2g.upload function.
I have tried exporting this to excel and then upload the data frame after reading it from the excel file but it's of no use.
I have also tried converting the multi index to object but no success.
df.index = pd.MultiIndex.from_frame(
pd.DataFrame(index=df.index)
.reset_index().astype(object)
)
I have tried other solutions from other threads but haven't been able to resolve this error.