Skip to content

Possible bug in df.update #29462

@isaacgg

Description

@isaacgg

Code Sample, a copy-pastable example if possible

test_json = [{"_id": 'a', 'date': datetime.now()}, {"_id": 'b', 'date': datetime.now()}]
test_df = pd.DataFrame(test_json)

new_df = test_df.copy()
new_df["date"] = None
new_df.update(test_df)

print(test_df.head())
print(new_df.head())

Problem description

When using update function with datetime data, it is automatically converted to timestamp, which for me it seems like an abnormal behaviour. Code from above would output

_id date
0 a 2019-11-07 15:50:06.072158
1 b 2019-11-07 15:50:06.072158
_id date
0 a 1573141806072158000
1 b 1573141806072158000

Expected Output

_id date
0 a 2019-11-07 15:50:06.072158
1 b 2019-11-07 15:50:06.072158
_id date
0 a 2019-11-07 15:50:06.072158
1 b 2019-11-07 15:50:06.072158

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 0.25.1
numpy : 1.16.4
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.2
setuptools : 41.0.1
Cython : 0.29.13
pytest : None
hypothesis : None
sphinx : 2.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.7.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions