Closed
Description
Create test DF.
df = pd.DataFrame({"uuid": [0,1,2,3,4], "publication_timestamp": ["2015-07-28 00:10:05.852", "2015-10-03 00:17:43.000", "2015-08-20 01:15:52.693", "2015-09-09 00:02:03.083", "2015-12-08 00:02:41.390"], "timezone": ["US/Central", "US/Eastern", "US/Eastern", "US/Pacific", "US/Mountain"]}).set_index('uuid')
publication_timestamp timezone
uuid
0 2015-07-28 04:10:05.852000+00:00 US/Central
1 2015-10-03 04:17:43+00:00 US/Eastern
2 2015-08-20 05:15:52.693000+00:00 US/Eastern
3 2015-09-09 04:02:03.083000+00:00 US/Pacific
4 2015-12-08 05:02:41.390000+00:00 US/Mountain
This call to map
works fine:
df.publication_timestamp.map(lambda x: x) # works fine
Localizing the datetime64 causes it to no longer have the map function
df['publication_timestamp'] = df.publication_timestamp.astype("datetime64[ms]").dt.tz_localize("UTC")
Doesn't work:
df.publication_timestamp.map(lambda x: x) # no longer works
Error Message
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-ba941613799a> in <module>()
----> 1 df.publication_timestamp.map(lambda x: x)
/Users/johria/.pyenv/versions/3.5.1/lib/python3.5/site-packages/pandas/core/series.py in map(self, arg, na_action)
2052 index=self.index).__finalize__(self)
2053 else:
-> 2054 mapped = map_f(values, arg)
2055 return self._constructor(mapped,
2056 index=self.index).__finalize__(self)
TypeError: Argument 'arr' has incorrect type (expected numpy.ndarray, got DatetimeIndex)
output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.17.1
nose: 1.3.7
pip: 8.0.3
setuptools: 19.4
Cython: None
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
IPython: 4.1.1
sphinx: 1.3.5
patsy: 0.4.1
dateutil: 2.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: 2.2.0-b1
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.4.2
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
Jinja2: 2.8