Reputation: 2257
I am reading xlsx file like this
df = pd.read_excel('cleaned_data.xlsx', header=0)
df = df.drop(df.columns[0], axis=1)
df.head()
Problem is column names coming as first row of data.
# reading data from csv file
df = pd.read_excel('cleaned_data.xlsx', header=0)
#df = df.drop(df.columns[0], axis=1)
df = df.drop(0, inplace=True)
df.head()
I tried this way but still not luck. Any suggestion?
Upvotes: 3
Views: 7621
Reputation: 862511
One idea is use header=1
:
df = pd.read_excel('cleaned_data.xlsx', header=1)
Another is skip first row:
df = pd.read_excel('cleaned_data.xlsx', skiprows=1)
Upvotes: 6