How to remove multiple headers from dataframe and keeps just the first python

前端 未结 3 781
梦谈多话
梦谈多话 2021-01-28 18:45

I\'m working with a csv file that presents multiple headers, all are repeated like in this example:

1                     2     3   4
0            POSITION_T  P         


        
3条回答
  •  再見小時候
    2021-01-28 18:59

    past_data=pd.read_csv("book.csv")
    
    past_data = past_data[past_data.LAT.astype(str).str.contains('LAT') == False]
    
    print(past_data)
    
    1. Replace the CSV (here: book.csv)
    2. Replace your variable names (here: past_data)
    3. Replace all the LAT with your any of your column name
    4. That's All/ your multiple headers will be removed

提交回复
热议问题