sumit
5/21/2019 - 9:03 AM

Read and write csv using pandas

Params for write.py mode = 'a' : for saving dataframe in already existing csv files, by default mode = 'w' it overwrites the file

pd.DataFrame(numpy_array).to_csv("file_name.csv", index=False, header = False, columns = ['a','b','c'])  
df = pd.read_csv("file_name.csv", index_col=None, header = None)  

# to make first row as header
df.columns = df.iloc[0]
df = df[1:]