The correct answer is: D. All of the mentioned
Pandas DataFrame columns can be accessed, set, and deleted using the same syntax as the analogous dict operations. For example, to access the value of a column, you can use the []
operator, just like you would with a dict. To set the value of a column, you can use the []=
operator. And to delete a column, you can use the del
keyword.
Here are some examples:
“`python
Create a DataFrame with two columns, A
and B
df = pd.DataFrame({‘A’: [1, 2, 3], ‘B’: [4, 5, 6]})
Access the value of the A
column
df[‘A’]
Output: array([1, 2, 3])
Set the value of the B
column to 7
df[‘B’] = 7
Delete the A
column
del df[‘A’]
The DataFrame now has only one column, B
df
Output:
B
0 7
1 7
2 7
“`
I hope this helps! Let me know if you have any other questions.