Skip to content

Commit 7ddbe9d

Browse files
committed
Fix extension dtype index handling
1 parent 0c06eac commit 7ddbe9d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

awswrangler/_data_types.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,14 @@ def pyarrow_types_from_pandas(
467467
# Filling indexes
468468
indexes: List[str] = []
469469
if index is True:
470-
for field in pa.Schema.from_pandas(df=df[[]], preserve_index=True):
470+
try:
471+
fields = pa.Schema.from_pandas(df=df[[]], preserve_index=True)
472+
except AttributeError as ae:
473+
if "'Index' object has no attribute 'head'" not in str(ae):
474+
raise ae
475+
# Get index fields from a new df with only index columns
476+
fields = pa.Schema.from_pandas(df=df.reset_index().drop(columns=cols), preserve_index=False)
477+
for field in fields:
471478
name = str(field.name)
472479
_logger.debug("Inferring PyArrow type from index: %s", name)
473480
cols_dtypes[name] = field.type

0 commit comments

Comments
 (0)