We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0c06eac commit 7ddbe9dCopy full SHA for 7ddbe9d
awswrangler/_data_types.py
@@ -467,7 +467,14 @@ def pyarrow_types_from_pandas(
467
# Filling indexes
468
indexes: List[str] = []
469
if index is True:
470
- for field in pa.Schema.from_pandas(df=df[[]], preserve_index=True):
+ 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:
478
name = str(field.name)
479
_logger.debug("Inferring PyArrow type from index: %s", name)
480
cols_dtypes[name] = field.type
0 commit comments