I read my data
import pandas as pd
df = pd.read_csv('/path/file.tsv', header=0, delimiter='\t')
print df
and get:
id text
0 361.273 text1...
1 374.350 text2...
2 374.350 text3...
How can I delete the id column from the above data frame?. I tried the following:
import pandas as pd
df = pd.read_csv('/path/file.tsv', header=0, delimiter='\t')
print df.drop('id', 1)
But it raises this exception:
ValueError: labels ['id'] not contained in axis
解决方案
To actually delete the column
del df['id'] or df.drop('id', 1) should have worked if the passed column matches exactly
However, if you don't need to delete the column then you can just select the column of interest li