Python pandas学习,绘制按月份的销售额,for循环构造一个pandas
# import numpy as np import pandas as pd dataPath = r'D:\\\\data.csv' df =pd.read_csv(dataPath) # 任务1:绘制按月份的销售额 columnName = r'1、请选择:日期' r = df.sort_values(by=columnName)# 这个就是我想要的排序算法 print("hello") type(df) df.head() index = df.index columns = df.columns type(columns) type(index) r = df.to_numpy() dataList = r[:,6] d =dataList[0] type(d) # 拿到日期。 list ,以及对应的key值?第6列 # dateList = data. sdf = df.sort_value(axis = 6, ascending=True) sdf = df.sort_value(axis = 8, ascending=True) df[0:3] df[0:0] print() # 查看一个元素的值? list = df['1、请选择日期:出货日期']#这个方式可以的 list1 = df.loc[dates[0]] list2 = df.iloc[:,5:5] ddd = df.iloc[5, 6] type(ddd) n = 6 r = df.iloc[:,n:n+1] rs = r sdf = df.sort_value('1、请选择日期:出货日期') df = pd.DataFrame({ 'one': pd.Series(np.random.randn(3), index=['a', 'b', 'c']), 'two': pd.Series(np.random.randn(4), index=['a', 'b', 'c', 'd']), 'three': pd.Series(np.random.randn(3), index=['b', 'c', 'd'])}) unsorted_df = df.reindex(index=['a', 'd', 'c', 'b'], columns=['three', 'two', 'one']) sorted_df = unsorted_df.sort_index(axis=1)#按照列的index进行排序 sorted_df = unsorted_df.sort_index(axis=0)#按照行的index进行排序 s1 = pd.DataFrame({"a": ['B', 'a', 'C'],"b": [1, 2, 3],"c": [2, 3, 4]}).set_index(list("ab")) s1 = pd.DataFrame({"a": ['B', 'a', 'C'],"b": [1, 2, 3],"c": [2, 3, 4]}) s1c = pd.DataFrame({"a": ['B', 'a', 'C'],"b": [1, 2, 3],"c": [2, 3, 4]}).set_index(list("ab")) df1 = pd.DataFrame({'one': [2, 1, 1, 1], 'two': [1, 3, 2, 4], 'three': [5, 4, 3, 2]}) df1.sort_values(by='two')# 这个就是我想要的排序算法 # 绘图画图(plot) import matplotlib.pyplot as plt # plot 函数怎么用 #任务2:
--------------