Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

“ValueError: labels ['timestamp'] not contained in axis” error

Asked by Jake Carter Jun 21, 2021 1.2K views 1 answer
Share

About this question

 I have this code, I want to remove the column 'timestamp' from the file: u.data but can't. It shows the error

"ValueError: labels ['timestamp'] not contained in axis"

How can I correct it

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt 
plt.rc("font", size=14)
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import Ridge
from sklearn.cross_validation import KFold
from sklearn.cross_validation import train_test_split
 
data = pd.read_table('u.data')
data.columns=['userID', 'itemID','rating', 'timestamp']
data.drop('timestamp', axis=1)
 
N = len(data)
print data.shape
print list(data.columns)
print data.head(10)


Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.