Jun-29-2021, 12:39 AM
If look at data so should it be turn around this is called transpose() if want data into Pandas for calculation, plot..ect.
If just want display data then can Yoriz method work.
To give example,just using first record.
If just want display data then can Yoriz method work.
To give example,just using first record.
record = {} with open('ca_data.txt') as f: header = next(f) for line in f: line = line.strip() line = line.replace('Time-zero ', '') line = line.split(':') line_1 = line[0].strip() line_2 = ''.join(line[1:]) record[line_1] = line_2.split() # Read like this so it fill in empty values with None df = pd.DataFrame.from_dict(record, orient='index') print(df)
Output:Lifetimes (ns) 0.4000 0.1250 2.0446
Std deviations 0.0588 None None
Intensities (%) 69.2721 9.6726 21.0553
Channel number 41.5603 None None
No can use transpose()
,then it will a useful DataFrame.>>> df = df.transpose() >>> df Lifetimes (ns) Std deviations Intensities (%) Channel number 0 0.4000 0.0588 69.2721 41.5603 1 0.1250 None 9.6726 None 2 2.0446 None 21.0553 None