I have data that looks like this.
state sex salary jordan CA m 100 lebron NY m 200
There are 4 columns however the first one does not have a column name. The other 3 columns are
sex, salary`. How do i initialize a data frame withe the above data?
I tried the following.
import pandas as pd data = [['jordan','CA','m',100], ['lebron','NY','m',200]] df = pd.DataFrame(data, columns = ['','state','sex','Age'])
When i do
df.columns I see
Index(['', 'state', 'sex', 'Age'], dtype='object')
However I expect to see
Index(['state', 'sex', 'Age'], dtype='object') when i do
So i am wondering how can i initialize the dataframe such that the column that has the names
lebron is not actually a column.
Source: Python Questions