I want to add a column name for each column but when I ran the code it shifted my column heading over two columns and added a two columns of NaN. What is causing this and is there a correction?
Another question; how do you pull a particular column with no columns names? I was trying df[0] (1,2, etc) but I receive an error.
df = pd.read_table('numcyc.dat', header=None, names = df_cols)
print(df)
place loc time
0 3 111.1 44 NaN NaN
1 3 111.1 34 NaN NaN
2 4 111.1 23 NaN NaN
3 2 111.1 16 NaN NaN
I want to add a column name for each column but when I ran the code it shifted my column heading over two columns and added a two columns of NaN. What is causing this and is there a correction?
Another question; how do you pull a particular column with no columns names? I was trying df[0] (1,2, etc) but I receive an error.
df = pd.read_table('numcyc.dat', header=None, names = df_cols)
print(df)
place loc time
0 3 111.1 44 NaN NaN
1 3 111.1 34 NaN NaN
2 4 111.1 23 NaN NaN
3 2 111.1 16 NaN NaN
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.