Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
df.to_excel() error.Unsupported type <type 'pandas._libs.interval.Interval'> in write() #19242
With pandas version 0.19.*,code can run normally.
But in pandas0.20+,the following error will be displayed.
import pandas as pd import numpy as np print(pd.__version__) df = pd.DataFrame(np.random.random((20, 2))) df['new'] = pd.cut(df, 10) df.to_excel('test.xlsx')
Note: The same error in pandas0.21,0.20. Right in 0.19.*
The Interval type was introduced in 0.20. Before then, it was just a string. The upcoming PR should fix it, but a quick fix is:
though not desirable if one wants to keep the Interval type in the data frame. Note that this exception comes up only when labels are not assigned. So:
should also work.