import pandas as pdimport matplotlib.pyplot as pltimport osplt.rcParams['font.sans-serif']=['SimHei']plt.rcParams['axes.unicode_minus']=Falsedef dataDescribeVisualization(): while True: fileName=input(' Please enter a file name to open presidential_polls_clinton_state_mean_lable.csv:') try: df_count=pd.read_csv(fileName,encoding='cp936') df_count=df_count.columns['Label'] df_count=df_count.value_counts() print(df_count) plt.figure() count_cut_counts.plot(kind='bar',figsize=(12,8)) plt.plot(df_count['Label'],df_count[' Number '],label=' Number ',color='blue') plt.xlabel("Label",fontsize=12)# Set up x Axis labels plt.ylabel(" Number ")# Set up y Axis labels plt.xticks(OneSup, TwoSup, ThreeSup, FourSup)# Set up x Axis scale plt.title(' Column Lable Number statistical histogram of ') plt.legend(figsize=16)# Display the legend and set the font size plt.savefig('presidential_polls_clinton_state_support.png',dpi=300) plt.show() print(" Mission 6 Successful implementation !") break except Exception as e: print(e)dataDescribeVisualization()import pandas as pdimport matplotlib.pyplot as pltimport osplt.rcParams['font.sans-serif']=['SimHei']plt.rcParams['axes.unicode_minus']=Falsedef dataDescribeVisualization(): while True: fileName=input(' Please enter a file name to open presidential_polls_clinton_state_mean_lable.csv:') try: df_count=pd.read_csv(fileName,encoding='cp936') df_count=df_count.columns['Label'] df_count=df_count.value_counts() print(df_count) plt.figure() count_cut_counts.plot(kind='bar',figsize=(12,8)) plt.plot(df_count['Label'],df_count[' Number '],label=' Number ',color='blue') plt.xlabel("Label",fontsize=12)# Set up x Axis labels plt.ylabel(" Number ")# Set up y Axis labels plt.xticks(OneSup, TwoSup, ThreeSup, FourSup)# Set up x Axis scale plt.title(' Column Lable Number statistical histogram of ') plt.legend(figsize=16)# Display the legend and set the font size plt.savefig('presidential_polls_clinton_state_support.png',dpi=300) plt.show() print(" Mission 6 Successful implementation !") break except Exception as e: print(e)dataDescribeVisualization()
Report errors :only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices