Skip to content

BUG: df1=df2.iloc[-1:] When a certain value of DF1 changes, the last line of DF2 follows DF1 on Pandas 2.1.3 #55988

@zhangyuxiang12

Description

@zhangyuxiang12

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
print(f'{day}日 初始Total_price2 {Stock_Holding_Total_Price_df}')
#day_Stock_Holding_Total_Price_df.loc[0]=Stock_Holding_Total_Price_df.iloc[-1]
day_Stock_Holding_Total_Price_df=Stock_Holding_Total_Price_df.iloc[-1:]
#day_Stock_Holding_Total_Price_df的date字段等于day
day_Stock_Holding_Total_Price_df.loc[0,'date']=day
print(f'{day}日 初始 day_Total_price{day_Stock_Holding_Total_Price_df}')
print(f'{day}日 赋值后的Total_price {Stock_Holding_Total_Price_df}')

Issue Description

When a certain value of DF1 changes, the last line of DF2 follows DF1 on Pandas 2.1.3

Expected Behavior

DF2 will never change

Installed Versions

INSTALLED VERSIONS

commit : 2a953cf
python : 3.10.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Chinese (Simplified)_China.936

pandas : 2.1.3
numpy : 1.26.1
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 63.2.0
pip : 23.3.1
Cython : None
pytest : None
hypothesis : None
...
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions