Screen Link:
My Code:
unrate['MONTH'] = unrate['DATE'].dt.month
fig = plt.figure(figsize=(6,3))
plt.plot(unrate[0:12]['MONTH'], unrate[0:12]['VALUE'], c='red')
plt.plot(unrate[12:24]['MONTH'], unrate[12:24]['VALUE'], c='blue')
plt.show()
What I expected to happen:
Expect to print both lines in the same chart.
What actually happened:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-36-0275face953d> in <module>
----> 1 unrate['MONTH'] = unrate['DATE'].dt.month
2 fig = plt.figure(figsize=(6,3))
3 plt.plot(unrate[0:12]['MONTH'], unrate[0:12]['VALUE'], c='red')
4 plt.plot(unrate[12:24]['MONTH'], unrate[12:24]['VALUE'], c='blue')
5 plt.show()
D:\Anaconda\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
5456 or name in self._accessors
5457 ):
-> 5458 return object.__getattribute__(self, name)
5459 else:
5460 if self._info_axis._can_hold_identifiers_and_holds_name(name):
D:\Anaconda\lib\site-packages\pandas\core\accessor.py in __get__(self, obj, cls)
178 # we're accessing the attribute of the class, i.e., Dataset.geo
179 return self._accessor
--> 180 accessor_obj = self._accessor(obj)
181 # Replace the property with the accessor object. Inspired by:
182 # https://www.pydanny.com/cached-property.html
D:\Anaconda\lib\site-packages\pandas\core\indexes\accessors.py in __new__(cls, data)
492 return PeriodProperties(data, orig)
493
--> 494 raise AttributeError("Can only use .dt accessor with datetimelike values")
AttributeError: Can only use .dt accessor with datetimelike values