Skip to content

Commit 82c6429

Browse files
committed
FIX: fixed adapter for feather files (via pyarrow) with pandas indexes
1 parent de0686e commit 82c6429

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

larray_editor/arrayadapter.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,16 @@ def get_values(self, h_start, v_start, h_stop, v_stop):
21362136
combined = pyarrow.concat_batches(batches)
21372137
else:
21382138
combined = batches[0]
2139-
return combined[v_start - chunk_start:v_stop - chunk_start].to_pandas().values
2139+
2140+
chunk = combined[v_start - chunk_start:v_stop - chunk_start]
2141+
2142+
# not going via to_pandas() because it "eats" index columns
2143+
columns = chunk.columns
2144+
np_columns = [c.to_numpy(zero_copy_only=False) for c in columns]
2145+
try:
2146+
return np.stack(np_columns, axis=1)
2147+
except np.exceptions.DTypePromotionError:
2148+
return np.stack(np_columns, axis=1, dtype=object)
21402149

21412150

21422151
@adapter_for('pyarrow.parquet.ParquetFile')

0 commit comments

Comments
 (0)