How to print a specific row of a pandas DataFrame?

前端 未结 5 1254
陌清茗
陌清茗 2021-01-29 23:01

I have a massive dataframe, and I\'m getting the error:

TypeError: (\"Empty \'DataFrame\': no numeric data to plot\", \'occurred at index 159220\')

5条回答
  •  有刺的猬
    2021-01-29 23:23

    To print a specific row we have couple of pandas method

    1. loc - It only get label i.e column name or Features
    2. iloc - Here i stands for integer, actually row number
    3. ix - It is a mix of label as well as integer

    How to use for specific row

    1. loc
    df.loc[row,column]
    

    For first row and all column

    df.loc[0,:]
    

    For first row and some specific column

    df.loc[0,'column_name']
    
    1. iloc

    For first row and all column

    df.iloc[0,:]
    

    For first row and some specific column i.e first three cols

    df.iloc[0,0:3]
    

提交回复
热议问题