Display/Print one column from a DataFrame of Series in Pandas

前端 未结 3 1699
闹比i
闹比i 2020-12-11 05:57

I created the following Series and DataFrame:

import pandas as pd

Series_1 = pd.Series({\'Name\': \'Adam\',\'Item\': \'Sweet\',\'Cost\': 1})
Series_2 = pd.S         


        
相关标签:
3条回答
  • 2020-12-11 06:11

    For printing the Name column

    df['Name']
    
    0 讨论(0)
  • 2020-12-11 06:13

    Not sure what you are really after but if you want to print exactly what you have you can do:

    Option 1

    print(df['Item'].to_csv(index=False))
    
    Sweet
    Candy
    Chocolate
    

    Option 2

    for v in df['Item']:
        print(v)
    
    Sweet
    Candy
    Chocolate
    
    0 讨论(0)
  • 2020-12-11 06:31

    By using to_string

    print(df.Name.to_string(index=False))
    
    
     Adam
      Bob
    Cathy
    
    0 讨论(0)
提交回复
热议问题