我有一个形状为6132,7的pyarrow表名为final_table,7我想向该表中添加列
list_ = ['IT'] * 6132
final_table.append_column('COUNTRY_ID', list_)但我得到了以下错误ArrowInvalid:添加的列的长度必须与表的长度匹配。预期长度为6132,但实际长度为12264
发布于 2020-08-11 16:40:01
根据documentation的说法
Append column at end of columns.
Parameters
field (str or Field) – If a string is passed then the type is deduced from the column data.
column (Array, list of Array, or values coercible to arrays) – Column data.
Returns
pyarrow.Table – New table with the passed column added.我认为pyarrow假设你提供了一个list of Array。为了避免混淆,您应该传递一个箭头数组
col_a = pa.array([1, 2, 3], pa.int32())
col_b = pa.array(["X", "Y", "Z"], pa.string())
table = pa.Table.from_arrays(
[col_a, col_b],
schema=pa.schema([
pa.field('a', col_a.type),
pa.field('b', col_b.type),
])
)
table.append_column('COUNTRY_ID', pa.array(['IT'] * len(table), pa.string()))https://stackoverflow.com/questions/63351189
复制相似问题