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
التالي · الدرس 7 من 42
Selecting Rows with loc & iloc
قراءة 1 دقيقة
أنهيت 6 من 42 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

