import pandas as pd column = "comment_text" processed_column = "processed" print("pandas version: ", pd.__version__) def print_df(df): for index, row in df.iterrows(): print("row_index: {}, row_text: {}".format(index, row[column])) # function to process the row # note: the function introduces a new column in the row def process_text(row): text = row[column] row [processed_column] = text.split(" ") return row # create data frame df = pd.DataFrame(columns=["text"]) # append dummy data for index in range(50): df = df.append({column: "{} doc doc doc {}".format(index, index)}, ignore_index=True) print("before processing") print_df(df) # process each of the rows df = df.apply(process_text, axis=1) print("after processing") print_df(df)