"1";" 00360 c3360eea3ef8648017ce3488f6a ";" The 2018-12-27 10:45:02 ";" 118.8207540 ";" 32.3732720 ";" 161389467 "," 27 "
"1";" 00360 c3360eea3ef8648017ce3488f6a ";" The 2018-12-27 10:45:53 ";" 118.8194490 ";" 32.3605400 ";" 84343044 "," 27 "
"1";" 00360 c3360eea3ef8648017ce3488f6a ";" The 2018-12-27 10:46:24 ";" 118.8196860 ";" 32.3586430 ";" 84343046 "," 27 "
"1";" 00360 c3360eea3ef8648017ce3488f6a ";" The 2018-12-27 10:48:57 ";" 118.8257510 ";" 32.3325110 ";" 9866397 "," 27 "
The extracted code:
The import pandas as pd
Table=pd. Read_csv (' userdata_31_clean. CSV, sep=', ', encoding="utf-8")
Len=table. Shape [0] # 2 d length
Ind.=pd Series (the list (range (len))) # to create a list of one dimensional array
data=https://bbs.csdn.net/topics/pd.DataFrame (index=(range (len)), the columns=(' id ', 'time', 'jd', 'wd)) # data to add a row
J=1
For I in the table. The iloc [0] :, : # iloc method is used to extract 0 column in the table data is read and I traversal
A=i. plit ('; ') # column with ";" Data segmentation in the I
C=[a [0], a [2], a [3], a [4]] # to create an array by, and composed of
Data. Values [j]=c # to add rows
J=j + 1
Print (data. The head () #
print data head
# data [' id ']=data [' id '] astype (" STR ")
Ind=data [' id '] drop_duplicates () for id # to heavy
For I in ind:
Data1=data. Loc [data [' id ']==I, :] # extract data (" id ")=I do
Name='userdata_' + I + 'CSV' # establishment I change the file
Data1. To_csv (name, index=False, encoding="GBK") # data1 to name the file storage, the Boolean type
The extracted results:
Id, time, jd, wd
1, "" "the 2018-12-27 10:46:24 ", "" "" "" "118.8196860 ", "32.3586430" "" "" "
1, "" "the 2018-12-27 10:48:57 ", "" "" "" "118.8257510 ", "32.3325110" "" "" "
1, "" "the 2018-12-27 10:49:02 ", "" "" "" "118.8254230 ", "32.3306620" "" "" "
1, "" "the 2018-12-27 10:49:07 ", "" "" "" "118.8275570 ", "32.3325600" "" "" "
1, "" "the 2018-12-27 10:54:40 ", "" "" "" "118.7770990 ", "32.2727000" "" "" "
How to delete the data extraction after excess "" "" "" or how to modify the code after the extraction of data without" "" "" "??
CodePudding user response:
Please look at the code, add a lambda expressions, or a function, reading the CSV file, replace the "CodePudding user response:
Replace directly, or the eval, can also be positive sideCodePudding user response:
Very thank you for the guidance of predecessors, the problem has been solved!