To deal with the first row as a column when reading a csv in python, you can use the header
parameter in the read_csv
function of the pandas module. The header
parameter allows you to specify which row to use as the column labels.
Example:
main.py72 chars5 lines
Here, we are passing a list [0]
to the header
parameter to specify that the first row should be used as the column labels. This will result in the first row being read as data instead of column headers.
gistlibby LogSnag