将数据框架存储为镶木木,并在一列中使用混合数据类型(时间戳和字符串)
我想将大熊猫的数据框架存储为镶木素文件。 但是我得到了这个错误:
pyarrow.lib.arrowtypeerror :( 转换为int”,'转换失败的columt 对象')
列具有混合数据类型。我认为这是问题。但是我该如何解决呢?
#!/usr/bin/env python3
import pandas
df = pandas.DataFrame(
data={
'foo': [pandas.Timestamp('2022-06-01'), 'foobar']
}
)
print(df)
I want to store a pandas data frame as Parquet file.
But I got this error:
pyarrow.lib.ArrowTypeError: ("object of type <class 'str'> cannot be
converted to int", 'Conversion failed for column foo with type
object')
The column has mixed data types. I assume this is the problem. But how can I solve that?
#!/usr/bin/env python3
import pandas
df = pandas.DataFrame(
data={
'foo': [pandas.Timestamp('2022-06-01'), 'foobar']
}
)
print(df)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
箭头仅支持具有定义明确的类型的结构化列数据,因此不支持混合类型。
但是,您可以使用Pyarrow Union类型。但这不是用户友好:
Arrow only supports structured column data with a well defined type, so mixed types are not supported.
However you could use the pyarrow union type. But it's not very user friendly: