Selecting Columns
Accessing columns is one of the most common operations in Pandas. There are multiple ways to select columns from a DataFrame.
Single Column Selection
Use bracket notation or dot notation:
Loading Pandas Playground...
Multiple Column Selection
Use double brackets with a list of column names:
Loading Pandas Playground...
Series vs DataFrame
Single bracket returns a Series, double brackets return a DataFrame:
Loading Pandas Playground...
Selecting by Data Type
Select columns based on their data type:
Loading Pandas Playground...
Exercise: Select Columns
Loading Exercise...
Exercise: Numeric Columns
Loading Exercise...
Key Points
df['column']returns a Seriesdf[['col1', 'col2']]returns a DataFrame- Dot notation
df.columnonly works for valid Python identifiers select_dtypes()filters columns by data type- Column order in result matches the order specified

