I have a function that accepts two arguments. for instance:
def sum(a,b):
s = a+b
return s
and I plan to make a dataframe using following pseudocode:
for a in range(1,10):
for b in range(100,200):
add(a,b)
and then i want to create a dataframe like:
DF:
A B Sum
1 100 101
1 101 102
1 102 103
1 103 104
...
I knwo i can do it in one line if I ahve only one forloop like :
df = pd.DataFrame([sum(a,b) for a,b in zip(range(1,10),range(100.200))],
columns=['A', 'B', 'Sum'])
However this will not repeat A for every B. How can i add a for loop inside another in one line?