I'm currently trying to build a fairly small dataset using the matplotlib and pandas libraries. The dataset format is a CSV file. Here is the dataset:
DATE,UNRATE
1948-01-01,3.4
1948-02-01,3.8
1948-03-01,4.0
1948-04-01,3.9
1948-05-01,3.5
1948-06-01,3.6
1948-07-01,3.6
1948-08-01,3.9
1948-09-01,3.8
1948-10-01,3.7
1948-11-01,3.8
1948-12-01,4.0
I uploaded the dataset using pandas (as you can see, the file that contains this dataset is called "dataset.csv"):
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('dataset.csv')
dataset['DATE'] = pd.to_datetime(dataset['DATE'])
Then I tried to build a loaded dataset using matplotlib:
plt.plot(dataset['DATE'], dataset['UNRATE'])
plt.show()
The above code basically worked fine and displayed the following graph:

However, the problem is that the data that I wanted to display on the x axis was apparently only built with an interval of two:

, "" x y matplotlib?, . , , , .
, x pyplot, , , . , , , to_pydatetime, DatetimeIndex. , pandas.to_datetime DatetimeIndex , to_pydatetime dataset['DATE']:
plt.xticks(dataset['DATE'].to_pydatetime())
:
AttributeError: 'Series' object has no attribute 'to_pydatetime'
, -, , matplotlib x, ?