HI, what if you want to create a similar function with takes 2 values? such that the 2 values will be 2 columns rather than using one column. The def function to take 2 columns instead of one, then use apply function
Awesome! Could you show an example taking in 2 parameters instead? Say taking Age and Gender... How do we achieve that using the function-apply approach?
This is an excellent Tutorial !!! . Beautifully explained, and you went over issues I have been struggling with. Thank you so much for taking the time to make this video
Great presntation. I am building a trading bot using algorythm that deals with conditional columns (candlestick lengths of previous columbs) This is the video I was looking for. Thanks for the vid. Very clear and informative. Exactly what I was looking for.
Hi, for example I have a table, which I've got by left outer join: person - vehicle dad - car dad - motorcycle dad - bicycle mom - car mom - bicycle son - None/NA/NaN/NaT How to group by person and count with condition (car and motorcycle)? When I use for example: df = df.groupby(['person'])['vehicle'].apply(lambda x: x[x == 'car'].count()) But I can't use a list in condition lambda x: x[x in ['car']], pandas says: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
What about if i have a column that contains several words (on each row) and i need to create a new column with 1s/0s IF ... my records contain a specific word AND (at same time) doesn't contain (another) specific word. I want to flag those records
Hi, you are doing awesomely work, explaining subject so easily to all, wondaful work, keep it up, could you explain OHLCV data, apply, map functions, user defined functions to to find the trend on the High, Low columns, to get buy signals and sell signals by not using any price lagging indicators.
Can u give me an example if using nested conditional? Because when I have tried my nested conditional with function and loop, the value in new coloumn is nan
This is great. But I need to do this for multiple columns. How do add values from another column to the new column without it affecting the existing values (except where there is null?
Oh man -- I've been trying to figure out more efficient ways of defining bins for a df. While I'm fairly new to Python, I've coded (in SAS) for 15 years, but that experience is only helpful in knowing how I would solve a coding problem -- in SAS. The numpy approach you mentioned is very simple and intuitive -- your tips are going to save me so much time! Thanks for making this video!!!
@@datagy we have two lists here, list a[] and b[] which contains some values, and the length of each lists is 60 thats why the for loop range is 60, then in the first 'if' condition if the 'i' value of the list a[] is greater then 'i' value of list b[] then the value of h will be 2 and we will append the value of h in the height[] list and similar condition is for second elif condition too but if both the condition fails then the value of h will be whatever the previous value of h, and i used temp variable to accomplish that....so how i will change all these scenarios according to the data frame......where list a and b are now two columns of the dataframe and instead of appending the values of h into a list i want to create a new column in the dataframe which will store it.....i hope that now it clears all the condition ......please help if possible.. it is like how can we compare 2 columns of a dataframe and if possible then how can we assign h the previous value when both the condition fails
@@Gaming_Hub47 Thanks for the explanation! I'm struggling to picture the flow of the data. Can you include the list a and b for me to better understand? Happy to try and help!