Extracting specific selected columns to new DataFrame as a copy

前端 未结 7 1911
忘了有多久
忘了有多久 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:34

    If you want to have a new data frame then:

    import pandas as pd
    old = pd.DataFrame({'A' : [4,5], 'B' : [10,20], 'C' : [100,50], 'D' : [-30,-50]})
    new=  old[['A', 'C', 'D']]
    
    0 讨论(0)
提交回复
热议问题