Complete the code to convert all column names in the DataFrame to lowercase.
df.columns = df.columns.[1]()Using lower() converts all column names to lowercase, which helps standardize them.
Complete the code to replace spaces in column names with underscores.
df.columns = df.columns.str.[1](' ', '_')
The replace() method replaces spaces with underscores in column names.
Fix the error in the code to remove leading and trailing spaces from column names.
df.columns = df.columns.str.[1]()The strip() method removes spaces at the start and end of strings.
Fill both blanks to create a dictionary that maps old column names to lowercase names without spaces.
new_names = {col: col.[1]().[2](' ', '_') for col in df.columns}This code makes a dictionary where each column name is first converted to lowercase, then spaces are replaced with underscores.
Fill all three blanks to rename columns by stripping spaces, converting to lowercase, and replacing spaces with underscores.
df.columns = df.columns.str.[1]().str.[2]().str.[3](' ', '_')
This chains methods: first strip() removes spaces around names, then lower() makes all letters lowercase, and finally replace() swaps spaces inside names with underscores.