#col_names = ['user_id', 'item_id', 'rating', 'timestamp']
data = pd.read_table(u.data, names=['user_id', 'item_id', 'rating', 'timestamp'])
data = data.drop('timestamp', axis=1)
data.info()
I ran the code above to read a file named 'u.data'. However, I am receiving the error below. Please help me how could I solve it.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-6a8b4f7064ed> in <module>
1 #col_names = ['user_id', 'item_id', 'rating', 'timestamp']
----> 2 data = pd.read_table(u.data, names=['user_id', 'item_id', 'rating', 'timestamp'])
3 data = data.drop('timestamp', axis=1)
4 data.info()
NameError: name 'u' is not defined
CodePudding user response:
'u.data' is string ?
data = pd.read_table('u.data', names=['user_id', 'item_id', 'rating', 'timestamp'])
CodePudding user response:
You should give the file name as a string like "C://u.data"