Issue
I have a very simple table in Excel that I'm trying to read into a DataFrame
Code:
from pandas import DataFrame, Series
import pandas as pd
df = pd.read_excel('params.xlsx', header=[0,1], index_col=None)
This results in the following DataFrame:
I didn't expect param1.key to become the index, especially after having set index_col=None
. Is there a way to get the data into a DataFrame with a generated index instead of the data from the first column?
Update — here's what happens when you try reset_index()
to resolve the issue:
Version info:
- Python 3.5.0
- pandas (0.17.1)
- xlrd (0.9.4)
Solution
It seems like a bug. You can get a column out of your index by simply doing:
df['columnName'] = df.index
Answered By - Blue Moon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.