Extracting specific selected columns to new DataFrame as a copy

前端 未结 7 1943
忘了有多久
忘了有多久 2020-12-04 04:59

I have a pandas DataFrame with 4 columns and I want to create a new DataFrame that only has three of the columns. This question is similar

7条回答
  •  臣服心动
    2020-12-04 05:32

    columns by index:

    # selected column index: 1, 6, 7
    new = old.iloc[: , [1, 6, 7]].copy() 
    

提交回复
热议问题