简体   繁体   中英

Pandas dataframe initialization changes the value of the original dataframe

Screenshot

Please look at the screenshot attached.

I created a Dataframe df then Initialized another Dataframe tesla which holds df

Then I perform my Manipulations on tesla and then when I check back on df

df has changed too.

Why is this happening?

I have been using Pandas for a long time now and haven't noticed this issue.

您应该使用copy ,然后在新df中应用更改时,它不会更改原始df

tesla=df.copy()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM