在将 Pandas 数据帧写入 S3 时出现了 AttributeError: 'DataFrame' object has no attribute '_mgr'
。
import awswrangler as wr
window = '0112'
wr.s3.to_csv(
df=mergeDf,
path="s3://MYBUCKET/wrangled/" + "WiderData_2" +window+ ".csv"
)
错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-65-30cb4c51bd25> in <module>
7 # Use 'w' for py3, 'wb' for py2
8 with s3.open('........','w') as f:
----> 9 mergeDf.to_csv(f)
.....
~/anaconda3/envs/python3/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
5272 """
5273 Return a Numpy representation of the DataFrame.
-> 5274
5275 .. warning::
5276
AttributeError: 'DataFrame' object has no attribute '_mgr'
也试过
import s3fs
s3 = s3fs.S3FileSystem(anon=False)
# Use 'w' for py3, 'wb' for py2
with s3.open('MYBUCEKT/wrangled/WiderData_1011.csv','w') as f:
mergeDf.to_csv(f)
同样的错误 'DataFrame' 对象没有 '_mgr' 属性的 AttributeError
这个错误通常是由于Pandas版本不兼容引起的。尝试更新Pandas版本或者检查代码中是否使用了已经被弃用的函数。
'B':[4, 5, 6],
'C':[7, 8, 9] } df = pd.DataFrame(data) dfimport boto3 import io import pandas as pd bucket='vz-bhr-ml-sha-inputdata' key='wrangled/test.csv' csv_buffer = io.StringIO() df.to_csv(csv_buffer) response = boto3.client('s3').put_object(Body=csv_buffer.getvalue(), Bucket=bucket, Key=key) df.to_csv(csv_buffer) -> 5274 5275 .. 警告:: 5276 AttributeError: 'DataFrame' 对象没有属性 '_mgr' - undefined