小编Car*_*los的帖子

将架构分配给 pa.Table.from_pandas()

使用 pyArrow 将 pandas.DF 转换为镶木地板时出现此错误:

ArrowInvalid('Error converting from Python objects to Int64: Got Python object of type str but can only handle these types: integer
Run Code Online (Sandbox Code Playgroud)

为了找出问题所在的列,我在 for 循环中创建了一个新的 df,首先使用第一列,然后为每个循环添加另一列。我意识到错误出现在dtype: object以 0 开头的列中,我想这就是为什么 pyArrow 想要将该列转换为int但失败的原因,因为其他值是UUID

我正在尝试传递一个架构:(不确定这是否是要走的路)

table = pa.Table.from_pandas(df, schema=schema, preserve_index=False)
Run Code Online (Sandbox Code Playgroud)

其中架构是: df.dtypes

python pandas parquet pyarrow

3
推荐指数
1
解决办法
9079
查看次数

python Cachetools 项目可以有不同的 ttl 吗?

我用来@cachetools.func.ttl_cache(maxsize=3, ttl=3600, timer=time.time, typed=False)缓存不同的数据帧。被包装的函数本身并不构建 DF,但给定参数会调用正确的函数。

鉴于我想修改项目 ttl(生存时间),根据参数,DF 的构建可能会很耗时或很快。因此,第 1 项的 ttl=3600,而第 2 项的 ttl=10800。

支持该功能吗?使用全局变量或任何其他方式?文档

python caching pandas

3
推荐指数
1
解决办法
3385
查看次数

标签 统计

pandas ×2

python ×2

caching ×1

parquet ×1

pyarrow ×1