Issue
df1
is this:
accel_name numb frequency resistance phase
idx
3 K 0 -33 1 4030
4 K 1 -16 2 4028
5 K 2 -18 12 4036
6 K 3 -14 -3 4054
12 K 4 -2 17 4048
13 K 5 -18 12 4048
df2
is this:
accel_name numb frequency resistance phase
idx
7 P 0 -452 4089 329
8 P 1 -428 4082 427
9 P 2 -382 4078 518
10 P 3 -363 4052 545
11 P 4 -347 4064 508
14 P 5 -373 4068 409
output :
- append df2 columns to df1
- output frequency.csv, resistance.csv, phase.csv
Solution
You can use df.to_csv()
to export the relevant dataframes
import os
import pandas as pd
filepath = os.getcwd()
df = pd.concat([df1, df2], axis=0).sort_index()
cols = ['frequency', 'resistance', 'phase']
for col in cols:
df[[col]].to_csv(filepath + '\\' + col + '.csv')
print(df)
accel_name numb frequency resistance phase
idx
3 K 0 -33 1 4030
4 K 1 -16 2 4028
5 K 2 -18 12 4036
6 K 3 -14 -3 4054
7 P 0 -452 4089 329
8 P 1 -428 4082 427
9 P 2 -382 4078 518
10 P 3 -363 4052 545
11 P 4 -347 4064 508
12 K 4 -2 17 4048
13 K 5 -18 12 4048
14 P 5 -373 4068 409
Output: frequency.csv, phase.csv, resistance.csv
Answered By - perpetualstudent Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.