I have a 'data' dataframe that contain col_names that have various column names within that dataframe. I need a new column corresponding to col_names for each row. In the following example, the new column (say D) should have 2 and 30 for first and second records respectively
import pandas as pd
# Initialise data to lists.
data = [{'col_names': 'b', 'b': 2, 'c':3}, {'col_names':'c', 'b': 20, 'c': 30}]
df = pd.DataFrame(data)