Efficient and readable solution using eval
\nKey ideas\n\n- The DataFrame.eval method lets you specify column assignment as a Python expression.\n- The Series.str attribute contains "vectorized string fu
\n**Key ideas**\n\n- The [`DataFrame.eval` method](https://pandas.pydata.org/docs/reference/api/pandas.eval.html#pandas.eval) lets you specify column assignment as a Python expression.\n- The [`Series.str` attribute](https://pandas.pydata.org/docs/reference/api/pandas.Series.str.html#pandas.Series.str) contains "vectorized string functions for Series and Index". This includes a [`title` method](https://pandas.pydata.org/docs/reference/api/pandas.Series.str.title.html) that is equivalent to "equivalent to [`str.title()`](https://docs.python.org/3/library/stdtypes.html#str.title)" in Python builtins.\n\n**Code**\n\n```pythondata []\nimport pandas as pd\n\ndef capitalize_content(user_content: pd.DataFrame) -> pd.DataFrame:\n    return (\n        user_content\n        .eval(\'converted_text = content_text.str.title()\')\n        .rename(columns={\'content_text\': \'original_text\'})\n    )\n```\n\nThe `eval` line creates a new column named `contexted_text` that has the string in column `context_text` but in "Title Case".\n\nThen, we simply rename the `context_text` column to `original_text`.
['Pandas']