How would you add a new column namely ‘val’ to a Dataframe df that has 10 rows in it and has columns as ‘Item’, ‘Qty’, ‘Price’ ? You can choose to put any values of your choice.

Ans:
to add a new column ‘val’ in dataframe ‘df’ we will write-
df[‘val’]=[12,23,45,43,55,12,23,43,11,29]
Here we are assigning 10 different values to ‘val’ column as df have 10 rows.

error: Content is protected !!