pandas的Panel类型dtype

时间:2023-12-16 23:36:20
panel = pd.Panel(dataframe_dict)
把一个多列类型不相同(里面有int,float)的dataframe字典直接赋值给Panel,从Panel中解析出来的dataframe的数据竟然全变成了float类型.

知道应该去修改dtype,但是bing,github搜索了半天没找到,后来尝试打印对象的属性panel.dtype,发现了object类型.原来官方文档上也有说明:
Columns with mixed types are stored with the object dtype.
panel = pd.Panel(dataframe_dict, dtype=object)