Skip to content

Commit a815852

Browse files
committed
FIX: fixed adapter for feather files (via pyarrow) with pandas indexes
1 parent 1b0ead0 commit a815852

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
@@ -2134,7 +2134,16 @@ def get_values(self, h_start, v_start, h_stop, v_stop):
21342134
combined = pyarrow.concat_batches(batches)
21352135
else:
21362136
combined = batches[0]
2137-
return combined[v_start - chunk_start:v_stop - chunk_start].to_pandas().values
2137+
2138+
chunk = combined[v_start - chunk_start:v_stop - chunk_start]
2139+
2140+
# not going via to_pandas() because it "eats" index columns
2141+
columns = chunk.columns
2142+
np_columns = [c.to_numpy(zero_copy_only=False) for c in columns]
2143+
try:
2144+
return np.stack(np_columns, axis=1)
2145+
except np.exceptions.DTypePromotionError:
2146+
return np.stack(np_columns, axis=1, dtype=object)
21382147

21392148

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

0 commit comments

Comments
 (0)