One. Import data
Import= pd.read_csv ('unrate.csv') unrate['DATE '] = pd.to_datetime (unrate['DATE')print( Unrate.head (12))
The results are as follows:
DATE VALUE0 1948-01-01 3.41 1948-02-01 3.82 1948-03-01 4.03 1948-04-01 3.94 1948-05-01 3.55 1948-06-01 3.66 1948-07-01 3.67 1948-08-01 3.98 1948-09-01 3.89 1948-10-01 3.710 1948-11-01 3.811 1948-12-01 4.0
Two. Using the Matplotlib Library
Import Matplotlib.pyplot as Plt # %matplotlib Inline # Using The different pyplot functions, we can create, customize, and display a plot. For example, we can use 2 functions to:plt.plot () plt.show ()
The results are as follows:
Three. Inserting data
First_twelve = Unrate[0:12]plt.plot (first_twelve['DATE'), first_twelve[' VALUE']) plt.show ()
Because the x-axis is too compact, the method of rotating the x-axis results in the following.
Plt.plot (first_twelve['DATE'), first_twelve['VALUE']) Plt.xticks (rotation=45)#print Help (plt.xticks)plt.show ()
Four. Setting the x-axis y-axis description
Plt.plot (first_twelve['DATE'), first_twelve['VALUE']) Plt.xticks (rotation=90) plt.xlabel ('Month') Plt.ylabel ( ' unemployment Rate ' ) plt.title ('Monthly unemployment Trends, 1948') plt.show ()
Use of Python visual library matplotlib