I have a list of Pandas DataFrames and I want to perform some operations on them. To be more precise, I want to clean their names and add new column. So I have written the following code:
import numpy as np
import pandas as pd
from janitor import clean_names
rng = np.random.RandomState(2019)
dataset = [pd.DataFrame(rng.randint(0, 10, (3, 3)), columns = ['Column A', 'Column B', 'Column C']) for i in range(4)]
for df in dataset:df = df.clean_names()df['column_d'] = df['column_a'] + df['column_b']
However, the changes are not preserved despite explicite assignment. The following code returns the original DataFrame:
dataset[1]Column A Column B Column C
0 8 5 3
1 0 2 5
2 7 8 5
What am I missing?