Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

python - Column names not found in DataFrame - can't delete them - "... not found in axis"

I have DF that looks like this:

    0   1   2   3   4   5   6   7   8   9   10  11  12  13
0   row-a49t-ihm3.rpap  00000000-0000-0000-05D6-978893D301BF    0   1604696511  None    1604696511  None    { } 2002    JAN 31106   49927   755015820   386481929
1   row-njtn_crc8_qawh  00000000-0000-0000-3211-E4A718B8A756    0   1604696511  None    1604696511  None    { } 2002    FEB 27520   50982   664454223   361353242
2   row-tn8d-5xax-gcqz  00000000-0000-0000-9FC0-AB50DEE551EE    0   1604696511  None    1604696511  None    { } 2002    MAR 34225   58794   805666244   419385387
3   row-bjnm-jnr7.7rbw  00000000-0000-0000-FE23-E2E416AC13DB    0   1604696511  None    1604696511  None    { } 2002    APR 36452   59817   846368297   433061150

0 1 2 3 4 5 6 7 8 9 10 11 12 13 are column names according to:

for col in df.columns:
    print(col)

Loop prints this:

0
1
2
3
4
5
6
7
8
9
10
11
12
13

However i can't delete them using this:

df.drop(columns=['0','1','2','3','4','5','6','7'], inplace=True)

If it changes anything DataFrame was imported from Json file. What is causing the issue - column names are correct?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...