Instagram
youtube
Facebook
Twitter

Select a Specific Column of a Pandas DataFrame

Select a Specific Column of a Pandas DataFrame
   
Short Description of the Program:

 This program reads data from a CSV file into a DataFrame and selects a specific column (e.g., 'Age') using its column name.
     
Explanation:

  • df['Age']
    This syntax selects the column named "Age" from the DataFrame.

     
  • You can replace 'Age' with any column name like 'Name', 'City', etc.
     

Program:

import pandas as pd

df = pd.read_csv('data.csv')

age_column = df['Age']

print(age_column)