Nov-21-2021, 11:53 AM
(This post was last modified: Nov-21-2021, 11:53 AM by buran.
Edit Reason: Fix problem with my code
)
I think you are overthinking/overcomplicating this problem.
Is it save to state that
Is it save to state that
- You want first 8 columns (i.e. A-H), then last 2 columns, then the 9th and 10th columns
- The column names for first 10 columns are the same as in the original file, the last 2 columns (former 9th and 10th) will have new header -
AttributeName
andAttributeValue
fname = 'VY6_Row1_report_url_detections_per_frame.csv' # fname = 'VY6_Row2_report_url_detections_per_frame.csv' df = pd.read_csv(fname) col_drop = len(df.columns) - 10 df['AttributeName'] = df[df.columns[8]] df['AttributeValue'] = df[df.columns[9]] df.drop(labels=df.columns[8:8+col_drop], axis=1, inplace=True) df.to_csv('VY6_out.csv', index=False)Do you need to use pandas? Using csv module would also do.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs