-
-
Couldn't load subscription status.
- Fork 19.2k
Description
Code Sample, a copy-pastable example if possible
# Your code here import pandas as pd df = pd.DataFrame([[1,2],[1,2]],columns=['a','b']) print df.apply(lambda x: {'s':x['a']+x['b']},1) ################ # (AS EXPECTED) # output: # 0 {u's': 3} # 1 {u's': 3} # dtype: object ################ # add one new column with type Timestamp df['tm'] = [pd.Timestamp('2017-05-01 00:00:00'),pd.Timestamp('2017-05-02 00:00:00')] print df.apply(lambda x: {'s':x['a']+x['b']},1) ################ #(WRONG OUTPUT) # output: # a b tm # 0 NaN NaN NaN # 1 NaN NaN NaN ################Problem description
when the return type of apply function is dict, if a new column with type Timestamp is added to the dataframe, the result will be unexpected even if the apply function is unchanged
Output of pd.show_versions()
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: zh_CN.UTF-8
LOCALE: None.None
pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.0.1
Cython: 0.25.2
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 5.4.1
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: 0.9.6
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: 1.1.14
pymysql: 0.7.11.None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None