Complete the code to add a new category 'D' to the categorical column.
import pandas as pd cats = pd.Categorical(['A', 'B', 'A', 'C']) cats = cats.add_categories([1])
Use a string in quotes to add a new category 'D'.
Complete the code to remove the category 'B' from the categorical column.
import pandas as pd cats = pd.Categorical(['A', 'B', 'A', 'C'], categories=['A', 'B', 'C']) cats = cats.remove_categories([1])
Remove category 'B' by passing it as a string in quotes.
Fix the error in the code to add multiple categories 'D' and 'E' to the categorical column.
import pandas as pd cats = pd.Categorical(['A', 'B', 'A', 'C']) cats = cats.add_categories([1])
To add multiple categories, pass a list of strings.
Fill both blanks to create a categorical column with categories 'A', 'B', 'C', then remove 'B'.
import pandas as pd cats = pd.Categorical(['A', 'B', 'C'], categories=[1]) cats = cats.remove_categories([2])
Set categories as a list and remove category 'B' as a string.
Fill all three blanks to add categories 'D' and 'E', then remove 'A' from the categorical column.
import pandas as pd cats = pd.Categorical(['A', 'B', 'C'], categories=[1]) cats = cats.add_categories([2]) cats = cats.remove_categories([3])
Start with categories A, B, C; add D and E; then remove A.
