-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
df.loc modifies datetime columns #28837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am not getting the same result on master, but I did get the same result as you on 0.25.1. It must have been fixed in the meantime and could use a regression test. Care to contribute a test?
|
Thanks. |
Sure. A new test |
Thanks @rohitsanj |
FYI I tested with 0.25.2 and the bug is still there. |
* TST: added test for df.loc modifies datetime columns Issue number #28837 * ran black pandas command * MAINT: Address reviewer comments
* TST: added test for df.loc modifies datetime columns Issue number pandas-dev#28837 * ran black pandas command * MAINT: Address reviewer comments
* TST: added test for df.loc modifies datetime columns Issue number pandas-dev#28837 * ran black pandas command * MAINT: Address reviewer comments
* TST: added test for df.loc modifies datetime columns Issue number pandas-dev#28837 * ran black pandas command * MAINT: Address reviewer comments
Code Sample, a copy-pastable example if possible
Problem description
Using
.loc[]
on datetime columns to assign values modifies the dates.When
.loc[]
is used on all the lines (df.loc[:, "date_dt_cp"] = df.loc[:, "date_dt"]
) the dates are unchangedbut when selecting only a subset of lines (
df.loc[[2,3], "date_dt_cp"] = df.loc[[2,3], "date_dt"]
), the values of the dates are changed:Expected Output
The last assignment in the example above shouldn't update the values:
Output of
pd.show_versions()
pandas : 0.25.1
numpy : 1.17.2
pytz : 2019.2
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : 0.29.10
pytest : 3.7.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : 7.3.0
pandas_datareader: None
bs4 : None
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.0.0
numexpr : 2.7.0
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.0
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : 1.3.0
xlsxwriter : None
The text was updated successfully, but these errors were encountered: