How to create a Dataframe from a list of variables corresponding to its value.
A = 10
B = 15
df = [A,B]
Output = [output]
How to create a Dataframe from a list of variables corresponding to its value.
A = 10
B = 15
df = [A,B]
Output = [output]
for your desired output:-
list1 = [a, b]
list2 = ['A', 'B']
pd.DataFrame(list(zip(list1, list2)), columns = ['Col1', 'Col2'])
I think this is the closest to answering your question:
import pandas as pd
before = locals().copy()
A = 10
B = 15
after = locals().copy()
diff = {key: val for key, val in after.items() if key not in before and key not in ['after', 'before']}
df = pd.DataFrame(diff.items())
print(df)