Home > Mobile >  Way to automatically name csv file from data frame in python without taking index and header from da
Way to automatically name csv file from data frame in python without taking index and header from da

Time:06-07

I have a Data Frame with one column consisting of Names
When i access the names from the dataframe as

filename = frcl.iloc[[i]]
file = open('' str(filename) '.csv', 'w')

It creates CSV file with name with index and header in the CSV File Name
Eg; if i have Apple and Bat in Dataframe it creates csv file with 00Apple.csv and 01Bat.csv
how to take dataframe content with out index and header?

CodePudding user response:

You can use panda's method to_string() and specify the argument index=False to avoid including the row's index.

filename = frcl.iloc[[i]].to_string(index=False)
file = open('' filename '.csv', 'w')
  • Related