I'm using awswrangler version 0.3.1
executing this:
import awswrangler as wr
wr.pandas.to_parquet(
dataframe=df,
path="s3://..."
)
results in:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-fae4f78166b2> in <module>()
----> 1 import awswrangler as wr
2 wr.pandas.to_parquet(
3 dataframe=df2,
4 path="s3://sherlock-raw/test_parquet/df.parquet"
5 )
~/anaconda3/envs/python3/lib/python3.6/site-packages/awswrangler/__init__.py in <module>()
15 from awswrangler.emr import EMR # noqa
16 from awswrangler.glue import Glue # noqa
---> 17 from awswrangler.pandas import Pandas # noqa
18 from awswrangler.redshift import Redshift # noqa
19 from awswrangler.s3 import S3 # noqa
~/anaconda3/envs/python3/lib/python3.6/site-packages/awswrangler/pandas.py in <module>()
17 from boto3 import client # type: ignore
18 from botocore.exceptions import ClientError, HTTPClientError # type: ignore
---> 19 from pandas.io.common import infer_compression # type: ignore
20 from pyarrow import parquet as pq # type: ignore
21 from s3fs import S3FileSystem # type: ignore
ImportError: cannot import name 'infer_compression'
it may have to do with the dependency on pandas 1.0.1
@vincentclaes thanks for report it.
1 - How did you install the Wrangler package? (Pip, Conda, Lambda Layer, Glue Wheel, Glue Egg)
2 - Which Python version?
3 - Can you execute a pip freeze and double check the versions of these packages, please:
- awswrangler
- pandas
- pyarrow
P.S. @tuliocasagrande
@vincentclaes thanks for report it.
1 - How did you install the Wrangler package? (Pip, Conda, Lambda Layer, Glue Wheel, Glue Egg)
2 - Which Python version?
3 - Can you execute apip freezeand double check the versions of these packages, please:
- awswrangler
- pandas
- pyarrow
P.S. @tuliocasagrande
1) !pip install awswrangler==0.3.1 (on a sagemaker instance with conda_python3 kernel)
2) Python 3.6.5 :: Anaconda, Inc.
3)
there is a function infer_compression on the 1.0.1 tag https://github.com/pandas-dev/pandas/blob/v1.0.1/pandas/io/common.py
Yeah, it is really strange.
You are right, this function does exist in this version of Pandas.
I've just tested the same code snippet here in my SageMaker notebook with the same Kernel and the same installation command and everything is working well.
I will keep investigating it, but let me know if you find out something in your side.
Hey guys, I double checked if pandas 1.0.1 still has infer_compression:
In [1]: import pandas as pd
In [2]: pd.__version__
Out[2]: '1.0.1'
In [3]: hasattr(pd.io.common, 'infer_compression')
Out[3]: True
Maybe the problem is with old .pyc files. Deleting them should be harmless as they're created again when needed. Can you give it a try, @vincentclaes?
To list:
find . -name "*.pyc"
To delete:
find . -name "*.pyc" -delete
Hey guys.
I have encountered the same problem, in a SageMaker instance, when I was trying to pip install "awswrangler" package.
I was getting "ImportError: cannot import name 'infer_compression'".
I solved this problem by pip installing the "awswrangler" BEFORE importing pandas. In this way I did not get this error!
I do not know or understand why .. but that was the solution that worked for me. Hope you guys can figure out the reason.
Hey @mksadoughi, thanks for sharing that.
Here are some findings:


Thank you for the contribution. Please, reopen the issue if it persists even after the version 1.0.0.
TL;DR
This error only happens if your environment has Pandas < 1.0.0. So please, update Pandas.
Most helpful comment
Hey @mksadoughi, thanks for sharing that.
Here are some findings: