Hi guys,
The codes in green below for importing csv was fine.
According to an online tutorial, the codes in red are supposed to generate a whole histogram containing xlabels and ylabels. However, when I tried it in Spyder, I computed the code in red individually and got each part of the graph separately. The "show.plt()" at the end returned a blank histogram with only ylabel.
Thanks for your help!
The codes in green below for importing csv was fine.
According to an online tutorial, the codes in red are supposed to generate a whole histogram containing xlabels and ylabels. However, when I tried it in Spyder, I computed the code in red individually and got each part of the graph separately. The "show.plt()" at the end returned a blank histogram with only ylabel.
Thanks for your help!
import pandas as pd import numpy as np import matplotlib.pyplot as plt import pandas as pd df_swing = pd.read_csv ('D:\\Dev\\DataCamp\\2008_swing_states.csv') plt.hist(df_swing['dem_share']) plt.xlabel('percent of votes for Obama') plt.ylabel('number of counties') plt.show()