为什么熊猫不会产生SettingWithCopyWarning?

2024-10-02 20:34:09 发布

您现在位置:Python中文网/ 问答频道 /正文

ufo.head(4)

输出

     City      Colors Reported  Shape Reported  State   Time
0   Ithaca        NaN            TRIANGLE         NY    6/1/1930 22:00
1   Willingboro   NaN             OTHER           NJ    6/30/1930 20:00
2   Holyoke       NaN              OVAL           CO    2/15/1931 14:00
3   Abilene       NaN              DISK           KS    6/1/1931 13:00

我在这里使用链分配,但警告不会生成

ufo['City'][0]='jain'
ufo.head(4)

输出

    City       Colors Reported  Shape Reported  State   Time
0   jain          NaN            TRIANGLE         NY    6/1/1930 22:00
1   Willingboro   NaN             OTHER           NJ    6/30/1930 20:00
2   Holyoke       NaN              OVAL           CO    2/15/1931 14:00
3   Abilene       NaN              DISK           KS    6/1/1931 13:00

Tags: citytimenanheadstateothercolorstriangle