Pandas selecting columns
I am following the machine learning tutorial and decided to use the python program on my laptop instead of SoloLearn. I have written a .csv file called ‘df’ on notepad and it can be read by my program (I know this because I am able to run head and other commands without issue). The problem occurs when I run the line ‘print(df[‘pclass’])’. Pclass is one of the headers. If I run this line using the header of the first column instead of pclass it works. How can I get the line to print the contents of the pclass column, or any of the other columns?
4/8/2020 1:46:13 PMCharlotte Stevenson
3 AnswersNew Answer
If your csv file has the correct structure, then it should work. Make sure you use the correct kind of apostrophe ' instead of the fancy ones you have in your question. Also make sure the column name is capitalized correctly same as in the csv (pclass and Pclass are different). If this doesn't help, post your error message and link your code in the playground.
Hello, thanks for your reply. I’m pretty sure that the csv file is in the right structure and the names are capitalised correctly. My error message is very long and refers to a part of the panda module called ‘index engine.get_loc’. Most of the issue seems to be occurring there.
Post your code in the playground and link it. https://www.sololearn.com/post/75089/?ref=app Otherwise it is really difficult to help you...