【发布时间】:2019-03-24 21:15:50
【问题描述】:
我正在尝试获取一个大的 csv 文件并为两列的排序编写一个 csv 文件。我能够从文件中获取两个单独的唯一值,以便能够知道需要创建哪些 csv 文件。
前数据:
1,224939.203,1243008.651,1326.774,F,C-GRAD-FILL,09/22/18 07:24:34,
1,225994.242,1243021.426,1301.772,BS,C-GRAD-FILL,09/24/18 08:24:18,
451,225530.332,1243016.186,1316.173,GRD,C-TOE,10/02/18 11:49:13,
452,225522.429,1242996.017,1319.168,GRD,C-TOE KEY,10/02/18 11:49:46,
我想创建一个 csv 文件“C-GRAD-FILL 09-22-18.csv”,其中包含与这两个值匹配的所有数据。我无法决定如何遍历这两个值的数据。
def readData(fileName):
df = pd.read_csv(fileName,index_col=False, names+['Number','Northing','Easting','Elevation','Description','Layer','Date'],parse_dates=['Date'] )
##Layers here!!!
layers = df['Layer'].unique()
##Dates here!!! AS DATETIME OBJECTS!!!!
dates = df['Date'].map(lambda t: t.date()).unique()
##Sorted in order
sortedList = df.sort_values(by=['Layer','Date'])
【问题讨论】:
标签: python pandas csv pandas-groupby