1 def load_csv(): 2 # 从csv文件读取股票日线数据 3 file = "data/300474.csv" 4 df = pd.read_csv(file, encoding="gbk") 5 # 数据以日期升序排序 6 df.sort_values(by="日期", ascending=True, inplace=True) 7 # 重置index为升序的值 8 df.reset_index(drop=True, inplace=True) 9 # 以条件获取数据 10 index = df.index[pd.to_datetime(df["日期"]) <= pd.to_datetime('2016-09-10')] 11 quote = df.loc[index] 12 print(index, "\n", quote)
标签:load,index,df,升序,csv,True,pandas From: https://www.cnblogs.com/dilex/p/16716327.html