You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
or any variation of it using map fails with the below error. Only a list comprehension works, so it doesn't seem possible to vectorize the operation. The error message is also confusing.
0 2018-01-01
1 2018-01-02
dtype: datetime64[ns]
0 (2018, 1, 1)
1 (2018, 1, 2)
dtype: object
[(2018, 1, 1), (2018, 1, 2)]
Traceback (most recent call last):
File "main.py", line 9, in <module>
print(pd.to_datetime(dates, utc=True).map(lambda x:x.isocalendar()))
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/pandas/core/series.py", line 3821, in map
new_values = super()._map_values(arg, na_action=na_action)
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/pandas/core/base.py", line 1300, in _map_values
new_values = map_f(values, mapper)
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/pandas/core/base.py", line 1287, in <lambda>
map_f = lambda values, f: values.map(f)
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/pandas/core/arrays/datetimelike.py", line 722, in map
return Index(self).map(mapper).array
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/pandas/core/indexes/multi.py", line 633, in array
raise ValueError(msg)
ValueError: MultiIndex has no single backing array. Use 'MultiIndex.to_numpy()' to get a NumPy array of tuples.
Problem description
While:
works as expected,
(i.e. just adding
utc=True
)or any variation of it using
map
fails with the below error. Only a list comprehension works, so it doesn't seem possible to vectorize the operation. The error message is also confusing.Example code
Try it here: https://repl.it/repls/RawClosedPorts
Output:
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: