I have a dataframe like the one displayed below:
# Create an example dataframe about a fictional army
raw_data = {\'regiment\': [\'Nighthawks\', \'Nighthawk
Loops are very slow instead of using apply function to each and cell in a row, try to get columns names in a list and then loop over list of columns to convert each column text to lowercase.
Code below is the vector operation which is faster than apply function.
for columns in dataset.columns:
dataset[columns] = dataset[columns].str.lower()