熊猫已弃用警告 to_dict()

Lug*_*öör 9 python deprecated pandas

我收到了这个已弃用的警告:

Using short name for 'orient' is deprecated. Only the options: ('dict', list, 'series', 'split', 'records', 'index') will be used in a future version. Use one of the above to silence this warning.
Run Code Online (Sandbox Code Playgroud)

使用任何此行时:

df.to_dict('records')
df.to_dict(orient='records')
df.to_dict(orientation='records')
Run Code Online (Sandbox Code Playgroud)

熊猫 v1.1.3 蟒蛇 v3.7.1

MUK*_*MUK 8

警告说“ orient”已被弃用。像这样使用它:

df.to_dict('records')

不要使用orient='',而是直接使用其中任何一个('dict', list, 'series', 'split', 'records', 'index'),例如:

df.to_dict('dict')

df.to_dict('list')

  • 警告消息会说,这正是我的假设。但 df.to_dict('records') 仍然引发警告 (9认同)

小智 5

我对同样的警告感到困惑。后来我发现我用的是“记录”而不是“记录”。在任何情况下,您都可以print(orient)在文件“pandas/core/frame.py”中在警告之前靠近 1485 的行处插入行。