Adding & Modifying Columns
Creating new columns and updating existing ones are fundamental DataFrame operations.
Adding a New Column
Assign values to a new column name:
Loading Pandas Playground...
Calculations Between Columns
Perform operations using multiple columns:
Loading Pandas Playground...
Conditional Column Values
Use conditions to set values:
Loading Pandas Playground...
Modifying Existing Columns
Update values in place:
Loading Pandas Playground...
Using assign() Method
Create columns without modifying original:
Loading Pandas Playground...
Insert Column at Specific Position
Use insert() to place column at an index:
Loading Pandas Playground...
Exercise: Calculate Tax
Loading Exercise...
Exercise: Conditional Status
Loading Exercise...
Key Points
df['new_col'] = valuesadds a column- Columns can be calculated from other columns
np.where()for if-else conditionsnp.select()for multiple conditionsassign()creates columns without modifying originalinsert(pos, name, values)for specific position
التالي · الدرس 15 من 42
The apply() Function
قراءة 1 دقيقة
أنهيت 14 من 42 درسًا

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

