Issue
I am trying to read a sample csv from the same folder as my .py file but am being presented with:
File "directory etc etc//untitled2.py", line 10, in <module>
data=pd.read_csv('Sample Data.csv')
TypeError: 'str' object is not callable
I am a little confused what this is being caused by as my code is exactly 2 lines long:
import pandas as pd
data=pd.read_csv('Sample Data.csv')
The contents of 'Sample Data.csv' is:
Student Id,Name
1,Oney
2,Twonie
3,Forthman
4,Forthman
5,Sixone
6,Fifthy
The directory looks as such:
I am aware this isn't specifically a coding question as I don't think there is anything wrong with the code but I would like to know what is causing this.
Confusingly the code worked until I tried to add further operations to it and now does not work even with everything removed bar the two lines quoted above.
I am using:
Spyder 3.3.6
Python 3.7.3 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10
Edit: Code added that broke it:
import pandas as pd
data=pd.read_csv('Sample Data.csv')
cleaner=pd.read_csv('Cleaning list.csv')
cleaner=list(cleaner.itertuples(index=False, name=None))
for a,b in cleaner:
data.loc[data['Student Id']==a,'Name'] = b
print(data)
Solution
I have not identified the cause of this but have 'fixed' it. Closing an reopening did not fix the problem but uninstalling and reinstalling Spyder did.
Answered By - William Wade
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.