I have an issue with strings. Is it possible to get data frame and column name out of string? Like below,
my input:
string = "df['homes']+df['age']"
I want this out of the string-like below
excepted output:
string = df['homes']+df['age']
Use pandas.eval
:
>>> import pandas as pd
>>> string = "df['homes']+df['age']"
>>> string = pd.eval(string)