我有兩個 Pyarrow Tables,想加入兩個。
A.join(
right_table=B, keys="A_id", right_keys="B_id"
)
現在我收到以下錯誤:
{ArrowInvalid} Incompatible data types for corresponding join field keys: FieldRef.Name(A_id) of type int8 and FieldRef.Name(B_id) of type int16
解決此問題的首選方法是什么?
我沒有找到將一列轉換為 pyarrow Table 中的 int8 或 int16 的方法。
謝謝
uj5u.com熱心網友回復:
您需要更改其中一張表的欄位型別。
如何更改表 A 的“A_id”欄位
# change type of 'A_id'
schema = A.schema
for num, field in enumerate(schema):
if field.name == 'A_id':
new_field = field.with_type(pa.int16()) # return a copy of field with new type
schema = schema.remove(num) # remove old field
schema = schema.insert(num, new_field) # add new field
A = A.cast(target_schema=schema) # update new schema to Table A
# join tables
A.join(
right_table=B, keys="A_id", right_keys="B_id"
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/510806.html
標籤:Python加入皮箭
上一篇:MySql查詢從左表中獲取所有行并從右表中獲取公共行
下一篇:使用CTE更新表
