Informatics Practices
You want to read data from a CSV file in a DataFrame but you want to provide your own column names to DataFrame. What additional argument would you specify in read_csv() ?
Python Pandas
4 Likes
Answer
To read data from a CSV file into a DataFrame while providing our own column names, we can use the names
argument in the read_csv()
function. The syntax is : <DF> = pandas.read_csv(<filepath>, names = <sequence containing column names>)
.
Answered By
2 Likes
Related Questions
What are advantages of CSV file formats ?
What all libraries do you require in order to bring data from a CSV file into a DataFrame ?
By default, read_csv() uses the values of first row as column headers in DataFrames. Which argument will you give to ensure that the top/first row's data is used as data and not as column headers ?
Which argument would you give to read_csv() if you only want to read top 10 rows of data ?