Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python switch columns order csv

import pandas as pd
df = pd.read_csv('/path/to/sample.csv')
df_reorder = df[['A', 'B', 'C', 'D', 'E']] # rearrange column here
#you may need to use zip(*[['A', 'B', 'C', 'D', 'E']])
df_reorder.to_csv('/path/to/sample_reorder.csv', index=False)
Comment

PREVIOUS NEXT
Code Example
Python :: python string remove whitespace 
Python :: tkinter canvas text size 
Python :: django x-frame-options allowall 
Python :: python os.walk recursive 
Python :: renpy 
Python :: pytest - parameterizing tests 
Python :: convex hull python 
Python :: random seed generator minecraft 
Python :: tkinter python 
Python :: Get request using python requests-html module 
Python :: pandas write csv 
Python :: swapping in python 
Python :: python index method 
Python :: fernet generate key from password 
Python :: python turtle delay 
Python :: jinja if or 
Python :: Swap first and last list elements 
Python :: python script to convert dicom to niftii 
Python :: box plot python 
Python :: list_display django foreign key 
Python :: how to make tkinter look modern 
Python :: how to add column to the Dataframe in python 
Python :: pandas rolling mean 
Python :: invert binary tree with python 
Python :: python - join two columns and transform it as index 
Python :: use gpu for python code in vscode 
Python :: jupyter matplotlib 
Python :: how to create barcode in python 
Python :: while loops python 
Python :: python datetime floor to hour 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =