Re: Pandas: How does df.apply(lambda work to create a result

2021-05-27 Thread Cameron Simpson
Disclaimer: I haven't actually used pandas. On 26May2021 14:45, Veek M wrote: >t = pd.DataFrame([[4,9],]*3, columns=['a', 'b']) > a b >0 4 9 >1 4 9 >2 4 9 I presume you've printed "t" here. So the above table is str(t). Or possibly repr(t) if you were at the interactive prompt. It is a

Pandas: How does df.apply(lambda work to create a result

2021-05-26 Thread Veek M
t = pd.DataFrame([[4,9],]*3, columns=['a', 'b']) a b 0 4 9 1 4 9 2 4 9 t.apply(lambda x: [x]) gives a[[1, 2, 2]] b[[1, 2, 2]] How?? When you 't' within console the entire data frame is dumped but how are the individual elements passed into .apply()? I can't do lambda x,y: [x,y]