Informatics Practices
Which argument would you give to read_csv() if you only want to read top 10 rows of data ?
Python Pandas
2 Likes
Answer
The nrows argument can be used to read only the top 10 rows of data from a CSV file using the read_csv() function in pandas. The nrows argument specifies the number of rows of the file to read. The syntax is : df = pandas.read_csv(<filepath>, nrows = 10).
Answered By
1 Like
Related Questions
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() ?
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 ?
Write command to store data of DataFrame mdf into a CSV file Mydata.csv, with separator character as '@'.
Why do you need connection to an SQL database in order to get data from a table ?