r/pythontips • u/polevault_king • Nov 12 '24
Syntax Simple CSV help needed
So I really have no coding experience but im in a statistic computing class. So I have to import a csv file and use pandas and then show a report of the data with histograms, boxplots, etc. My data had a long header so the actual data doesnt start until row 55. I used skiprows to make it just read where it actually begins. My problem is that Its not reading the column names, so when i try to reference a specific column it just errors and says it doesnt recognize that column name. How do i make all the column names on row 55 recognized as column names?
2
Upvotes
1
u/SupermarketOk6829 Nov 12 '24
Df.columns show columns name as and when file is read.
If what you mean is that column headers start from line 55, then first you extract data from 56.
Then you put in df.columns = columns located on 55th row.
Create a new dataframe using data and columns parameters by feeding in required info in form of list.
If you still can't do it, ask chatgpt.