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
>>> import pandas
>>> x = pandas.Series([1,2,3], index=['Date','b','other'])
>>> x
Date 1
b 2
other 3
dtype: int64
>>> from datetime import date
>>> x.Date = date.today()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37\lib\site-packages\pandas\core\generic.py", line 4405, in __setattr__
self[name] = value
File "C:\Python37\lib\site-packages\pandas\core\series.py", line 939, in __setitem__
setitem(key, value)
File "C:\Python37\lib\site-packages\pandas\core\series.py", line 935, in setitem
self._set_with(key, value)
File "C:\Python37\lib\site-packages\pandas\core\series.py", line 983, in _set_with
self._set_labels(key, value)
File "C:\Python37\lib\site-packages\pandas\core\series.py", line 993, in _set_labels
raise ValueError('%s not contained in the index' % str(key[mask]))
ValueError: ['D' 'a' 't' 'e'] not contained in the index
>>> x.b = date.today()
>>> x.b
datetime.date(2018, 11, 1)
>>> x
Date 1
b 2018-11-01
other 3
dtype: object
>>>
Problem description
I cannot put a date object in a Series if the index is a string with len > 1.
It works if it's only a single character. Other types seem to work. I've only seen the problem with dates.
The text was updated successfully, but these errors were encountered:
Code Sample
Problem description
I cannot put a date object in a Series if the index is a string with len > 1.
It works if it's only a single character. Other types seem to work. I've only seen the problem with dates.
The text was updated successfully, but these errors were encountered: