I currently have the following code:
import glob
import pandas as pd
path_pattern = 'C:/Users/Joey/Desktop/GC results/Results/FID_00*'
files = glob.glob(path_pattern)
dataframes = [pd.DataFrame.from_csv(f, index_col=None) for f in files]
new_df = pd.DataFrame()
for i in dataframes:
selected_data = i['Unnamed: 3'].ix[12:16]
new_df['Run'] = selected_data
print new_df
out:
Run
12 5187666.22
13 1453339.93
14 193334.09
15 157630.92
16 98943.96
Run
12 5188329.28
13 1455640.31
14 193074
15 157420.83
16 98791.72
Run
12 5188943.17
13 1456575.95
14 192977.15
15 157325.56
16 98699.43
Run
12 5188675.1
13 1456622.43
14 192796.99
15 157174.61
16 98598.53
Run
12 5187783.26
13 1456612.29
14 192703.05
15 157078.52
16 98511.48
At the moment, the selections are all in the same column. Is it possible to reorganize this such that each selection 12-16 is a separate column? I would like run1, run2, ..., run6 to be 6 separate columns.
Select desired data using using
.ix
and add selected data (type: pd.Series) to a new dataframe: