Тёмный

How do I apply a function to a pandas Series or DataFrame? 

Data School
Подписаться 244 тыс.
Просмотров 202 тыс.
50% 1

Have you ever struggled to figure out the differences between apply, map, and applymap? In this video, I'll explain when you should use each of these methods and demonstrate a few common use cases. Watch the end of the video for three important announcements!
Subscribe to the Data School email newsletter: www.dataschool....
Join "Data School Insiders" for exclusive rewards: / dataschool
== DATA SCHOOL VIDEO TUTORIALS ==
Data analysis with pandas (30 videos): • Data analysis in Pytho...
Machine learning with scikit-learn (10 videos): • Machine learning in Py...
Version control with Git and GitHub (11 videos): • Version control with G...
== PANDAS RESOURCES ==
GitHub repository for the series: github.com/jus...
Series "map" documentation: pandas.pydata.o...
Series "apply" documentation: pandas.pydata.o...
DataFrame "apply" documentation: pandas.pydata.o...
DataFrame "applymap" documentation: pandas.pydata.o...
== RELATED PANDAS VIDEOS ==
loc, iloc, and ix: • How do I select multip...
string methods: • How do I use string me...
== JOIN THE DATA SCHOOL COMMUNITY ==
Blog: www.dataschool.io
Newsletter: www.dataschool....
Twitter: / justmarkham
Facebook: / datascienceschool
RU-vid: www.youtube.co...

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 484   
@sak8485
@sak8485 5 лет назад
Dude , you're the Corey Schafer of Pandas.
@dataschool
@dataschool 5 лет назад
Ha! Corey is a friend of mine and a great educator, so I take that as a huge compliment 😄
@RoylanMartinez
@RoylanMartinez 4 года назад
haha
@파이썬으로머신러닝배
Awesome. I think it is especially super useful for non-English speakers as your English is clear and slow. Thank you very much.
@dataschool
@dataschool 5 лет назад
You're very welcome!
@cradleofrelaxation6473
@cradleofrelaxation6473 10 месяцев назад
No doubt one of the greatest teachers on RU-vid!! So calm and graceful ‼️
@dataschool
@dataschool 9 месяцев назад
You are so kind, thank you!
@carlosportillo6815
@carlosportillo6815 3 года назад
Hands down, one of the best Pandas instructor in YT!
@dataschool
@dataschool 3 года назад
Thank you!
@marcosylinafeijoo9966
@marcosylinafeijoo9966 7 лет назад
Great Series: I have learned so much. You are one of the best teachers I have ever seen.
@dataschool
@dataschool 7 лет назад
Wow, thank you so much! I really appreciate your compliment!
@jongcheulkim7284
@jongcheulkim7284 2 года назад
Thank you again. whenever I watch this again, I am learning new.
@dataschool
@dataschool 2 года назад
Great to hear!
@philiperiskallaleal6010
@philiperiskallaleal6010 6 лет назад
Thanks for everything. Every minute here invested has been most valuable. Awesome videows. Super didactic!
@dataschool
@dataschool 6 лет назад
Thanks!
@rajsoniism
@rajsoniism 4 года назад
every minute i spent here more than worthy.The way you teach to really good.
@dataschool
@dataschool 4 года назад
Thank you! 🙏
@TheOntheskies
@TheOntheskies 3 года назад
Thank you. Your explanations are well-paced and easy to understand and most importantly sticks to memory.
@dataschool
@dataschool 3 года назад
Thanks for your kind words! 🙏
@potentialada
@potentialada 8 лет назад
Thanks for the great series. Your videos have given me a good foundation in pandas. With what I have learned here I have already been able to generate several data clean-up scripts, and run data analysis that I have presented at an academic conference using only pandas. Great work!
@dataschool
@dataschool 8 лет назад
Wow! That's awesome, I'm so glad to hear this series has been helpful to you!
@sagarghimire
@sagarghimire 7 лет назад
Hi Kevin, how do I lookup a column values in one datra frame against the second data frame, say column 1 and get the corresponding data from column 2 of second data frame and add that results to first data frame.
@lindsaybreidenbach8658
@lindsaybreidenbach8658 4 года назад
Saved my butt for finishing my hw today. Thx!
@dataschool
@dataschool 4 года назад
That's awesome to hear!
@Ganeshkakade454
@Ganeshkakade454 2 года назад
Hey...great Series Sir..learning Pandas module from your side is such a boon..Thanks,Love from India!!!
@dataschool
@dataschool 2 года назад
Thank you!
@astitvasrivastava7197
@astitvasrivastava7197 4 года назад
we can also get the first element of the list of strings by using : train.Name.str.split( ' , ' ).str.get( 0 )
@surbhiagrawal3951
@surbhiagrawal3951 4 года назад
Hey Yours above solution worked fine for me but when i am trying with apply function , it is giving me error TypeError: 'float' object is not subscriptable Also the list which i am passing is a list of strings only . def tryfunc(list1,position): return list1[position] hi["new"]=hi["WebframeDesireNextYear"].str.replace(".", "").str.split(";").apply(tryfunc,position=0)
@MagnusAnand
@MagnusAnand 2 года назад
EVERYBODY: remember to always use vectorized operations when possible. They are many orders of magnitude faster than using "apply", which is not vectorized. - For instance, instead of: drinks.loc[:,'beer_servings':'wine_servings'].apply(max, axis=0) - Use: drinks.loc[:,'beer_servings':'wine_servings'].max()
@riderblack6401
@riderblack6401 7 лет назад
Best python tutorials in the sea of the net you can dig. I promise subscribe it!
@dataschool
@dataschool 7 лет назад
Thanks so much for subscribing, and for your kind comments!
@dineshpandey5008
@dineshpandey5008 Год назад
Thanks for this , It is really helpful, but in my case, it returns 0 and 1 instead of column label df.loc[:,'Parle':'Soap'].apply(np.argmax,axis=1)
@aleksandramazurek1364
@aleksandramazurek1364 5 лет назад
This is amazing! The way you explain the complicated stuff is fenomenal, thank you
@dataschool
@dataschool 4 года назад
Thanks, I really appreciate your kind words!
@taikoktsui_sithlord
@taikoktsui_sithlord Год назад
Superb tutorial. Thanks so much!
@dataschool
@dataschool Год назад
Thanks for your kind words!
@DookyButter
@DookyButter 3 года назад
@Data School, I did some testing and I have found that if you type the lambda function @10:35 a little differently, you get a more efficient processing time: import timeit tic = timeit.default_timer() train.Name.apply(lambda x: x.split(',')[0]) # Method 1 toc = timeit.default_timer() method1 = toc-tic print('Method 1:', method1) ticktic = timeit.default_timer() train.Name.str.split(',').apply(lambda x: x[0]) # Method 2 toc = timeit.default_timer() method2 = toc-tic print('Method 2:', method2) if method1 < method2: print(f'Method 1 is faster by {method2/method1} times.') else: print(f'Method 2 is faster by {method1/method2} times.')
@dataschool
@dataschool 3 года назад
Thanks for sharing! 🙌
@MrBhargavafirst
@MrBhargavafirst 4 года назад
very knowledgeful thanks for this
@dataschool
@dataschool 4 года назад
You're welcome!
@NroShock
@NroShock 4 года назад
Thank you so much for the time and effort you have put into your video series, and the amazingly well documented Jupyter Notebook with everything from the series!
@dataschool
@dataschool 3 года назад
Thanks for appreciating!
@Amitsingh-mh3lx
@Amitsingh-mh3lx 3 года назад
your video helping me to much thanks from india
@mansiarora5899
@mansiarora5899 4 года назад
Great videos 👍 I have learnt a lot from them. I have one question it would be very great if you find time to answer this. I have a list of string values and I am trying to create a new column and the value should be 1 if the value given in the list exists in any of the column of dataframe else the value should be 0. Eg. There is a dataframe with cols A,B,C,D and I have a list names test which has some values in it. If the value exists in either A,B,C or D then the first row of new col E should have 1 else 0 and similarly for the next row
@ahmadaburizaiza6598
@ahmadaburizaiza6598 7 лет назад
Thank you so much for this video and for all the other videos in your amazing channel. I just found a solution in this video for a problem I was struggling with :)
@dataschool
@dataschool 7 лет назад
Awesome! Great to hear! :)
@DonDynAyt
@DonDynAyt 6 лет назад
First of all, thank you very much for the time and effort you put into this video series it has been very helpful. Moreover, would you know how to subtract from a column a substring that is in another column?
@dataschool
@dataschool 6 лет назад
There's probably a string method that can help you, but I don't know which one off-hand... sorry!
@임은총-t2z
@임은총-t2z 6 лет назад
I love you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@dataschool
@dataschool 6 лет назад
:)
@PradeepKumar6
@PradeepKumar6 8 лет назад
Thanks Kevin for such a nice tour on pandas....I enjoyed it a lot. By the way, In future if you decide to start it again, please enlighten us with the "Reduce" function as well. Thanks again for helping people so much. I know it is really hard to make a video. It takes lot of time and effort. Take Care, Good luck to your projects
@dataschool
@dataschool 8 лет назад
Thanks so much for your kind words! Glad the pandas series has been helpful to you. You're right, it is a ton of effort to make the videos, but definitely worth it :)
@niravnaik6947
@niravnaik6947 Год назад
Brother you look like Dr. Sheldon Cooper from tbbt 😂 Nice explanation 😊
@dataschool
@dataschool Год назад
Thanks! 😄
@louisbademosi9250
@louisbademosi9250 3 года назад
You know you like a channel when you find yourself trying to subscribe only to find that you already have
@dataschool
@dataschool 2 года назад
Thank you! 🙏
@ItsWithinYou
@ItsWithinYou 3 года назад
Excellent! I am much clear now on this topic...Many thanks!
@dataschool
@dataschool 3 года назад
You are welcome!
@esdrasdebrito
@esdrasdebrito 6 лет назад
very good examples. Thank you so much
@dataschool
@dataschool 6 лет назад
You're welcome!
@yossarian2909
@yossarian2909 6 лет назад
Lucid explanations.. i love your channel!!
@dataschool
@dataschool 6 лет назад
Thanks!
@nasreenbanu2245
@nasreenbanu2245 2 года назад
Hats off to you .You made me pro in coding.Thanks a lot..keep going
@dataschool
@dataschool 2 года назад
Thank you!
@calluma8472
@calluma8472 4 года назад
At 10:35, could we use a lambda function as follows: train.Name.apply(lambda x: x.split(',')[0]) or is that a bad way to do it? PS very much appreciate this video and your whole way of walking through these topics.
@dataschool
@dataschool 4 года назад
Yes, I think so, but I'd have to verify. Glad you like the videos! 👍
@achintyaagarwal5391
@achintyaagarwal5391 5 лет назад
''' train.ix[ 0:2 , ['Name','Name_length'] ] ''' gives the same result as '''' train.loc[ 0:2 , ['Name','Name_length'] ] '''' but throws a warning of .ix is depreciated. ix can take a combination of integer and label, then why this warning. I have watched the loc, iloc, ix video but i couldn't figure this out. I just couldn't understand the meaning of the warning. P.S.- Your videos are a huge help in my learning of python which was going a bit boring by books. Keep up the good work :-)
@dataschool
@dataschool 5 лет назад
Great question! A function being deprecated doesn't mean you are doing anything wrong. It just means you are using a function that they no longer recommend you use, and they are planning to remove from the library in the future.
@nghiepcrypto7034
@nghiepcrypto7034 4 года назад
Can we do data analysis only with Python? Because I've heard that just python is getting popular these days, many people learns python. But we should focus on sql and excel skills to master data analysis.
@navishagarwal1736
@navishagarwal1736 4 года назад
A clarification on the apply function. In the example where you apply it on the Name series, how is it that you can use the str.split function on the 'Name' series without the apply function in the dataframe but for 'len' you need to use the apply function?
@souraneelmandal7912
@souraneelmandal7912 3 года назад
Hi Kevin, Thanks soo much for the series. Can you make videos on regex or regular expression in pandas..?
@dataschool
@dataschool 3 года назад
Thanks for your suggestion!
@batibot1
@batibot1 3 года назад
I am super late coming to this video. My question is on the apply method. If I have a dataframe apply function on axis=1, how do I know or how can I reference the column name in the function when I get an exception?
@brendensong8000
@brendensong8000 3 года назад
Thank you for sharing! I learn so much from every video!
@dataschool
@dataschool 3 года назад
I'm so glad!
@WaltterValdez
@WaltterValdez 8 лет назад
Thanks a lot for your time It has been very helpful for me
@dataschool
@dataschool 8 лет назад
You're very welcome! Thanks for joining me for the series :)
@aminsama
@aminsama 5 лет назад
this helped me in better understanding the fundamental difference. thank you so much.
@dataschool
@dataschool 4 года назад
You're very welcome!
@fernandotorres1203
@fernandotorres1203 7 лет назад
Thanks man for making these videos.
@dataschool
@dataschool 7 лет назад
You're very welcome! I enjoyed creating them :)
@riderblack6401
@riderblack6401 7 лет назад
awesome vid! I learn so so Much from you Kevin! Keep it up!
@dataschool
@dataschool 7 лет назад
Thanks! I appreciate your support.
@bloomingtonvolleyball639
@bloomingtonvolleyball639 5 лет назад
You are such an awesome tutor that I felt this is the best channel for pandas. Please keep posting. Thanks a lot.
@dataschool
@dataschool 5 лет назад
Thanks so much!
@ursulaforever
@ursulaforever 5 лет назад
Mate you are the best!
@dataschool
@dataschool 5 лет назад
Thank you!
@mobix6354
@mobix6354 4 года назад
Hey, np.argmax returns the indicies not the column name. I'm guessing the function changes over time. Could you tell use how to get the column names instead?
@chicorebello
@chicorebello 4 года назад
I have the same issue. Did you figure it out?
@RavinderSaluja
@RavinderSaluja 3 года назад
@@chicorebello Use df.idxmax(axis=1). That should do the trick.
@user-lgmiyhy
@user-lgmiyhy 6 лет назад
Frist of all, I appreciate your effort of making this kind of video clips very useful for beginers. I have a question to ask. If possible, please tell me how to deal with it? What I want to ask is, I have a DataFrame which has a string data column, Code, object type, and a integer column, Points. I want to create a new Series in the DataFrame for giving grade from 'A' to 'Z' according the Points referring to the Code. In this point, The Code is a very Important key. Code 'VIP' has a spectrum between 10000~ 20000, and the others have it under 5000. So before giving grade, I have to check the Code first. It's OK for me to make it out using functions. But I want to make it out another way for using Pandas' way such as dealing whole Column data just in one shot.....instead of using array functions having i,j... And more, if I need to refer another DataFrame, which has only few records for range guideline of grades, for giving a decision on the Points, what should I do? please send me a message to lgmiyhy@gmail.com if possible. I would appreciate it if I have an an answer from you.
@dataschool
@dataschool 6 лет назад
Sorry, it's hard for me to completely understand your question... best of luck to you!
@Genetics101
@Genetics101 7 лет назад
super clear and very helpful. thanks!
@dataschool
@dataschool 7 лет назад
You're very welcome!
@dunwally2433
@dunwally2433 5 лет назад
Thanks for this great work, Kevin. My question is on the use of the apply function to Series. Why is the Fare value not approximated correctly to the nearest unit using method "apply(np.ceil)"? For example: 7.2500 = 7.0 and not 8.0
@dataschool
@dataschool 5 лет назад
It is being rounded up as it should - this is the ceiling method, not the round method. Hope that helps!
@delascasayukarrey8469
@delascasayukarrey8469 3 года назад
hello Kevin, thanks for the video. How can I fill in missing values in one column , based on the values in another column. for example,I would like to fill in the missing values in the ''Sex'' column based on the titles in the ''Name'' column. so if the title is Mr. I should fill in Male. And if it is Miss or Mrs. I should fill in female. thanks.
@denisechen5017
@denisechen5017 6 лет назад
Hi ! Thank you for your through tutorial. When using np.argmax, it shows which column is maximum When I run the code, it shows that argmax is deprecated. Are there any way able to fix this problem? Thank you!!!!
@dataschool
@dataschool 6 лет назад
I'm sure there is, but I don't know it off-hand. Sorry!
@chinamyx
@chinamyx 3 года назад
Hey thanks for sharing! You lessons are clear
@dataschool
@dataschool 3 года назад
Thanks!
@MrGleyce1
@MrGleyce1 3 года назад
Just amazing! thanks a lot for sharing your knowledge.
@dataschool
@dataschool 3 года назад
Thank you!
@annalukowska7080
@annalukowska7080 2 года назад
Hi , How do I select specific columns based based on row condition please? If Row= value1 select only 2 columns or if Row=vaule2 select 3 columns so on. Thanks
@robertbriscoe277
@robertbriscoe277 4 года назад
You make great videos! Have you ever made one to address how to iterate through a pandas data frame row by row: and for each row look at the previous row, column x, apply logic, then calculate current row column x. I can not find a way to do this that does not return a copy of original data frame for the logic instead of the values that are being calculated in the iteration. Thanks
@sivakavin6090
@sivakavin6090 3 года назад
Hi Master Kevin , Actually i tried below argmax method in my data as you suggest. # finding out the which argument is max drink.loc[:,'beer_servings':'wine_servings'].apply(maxBeer,axis=1) My output: showing index value of the argument ultimately argmax do that only. So I written function externally to get string value. which written below. # String value for index def maxBeer(a): if np.argmax(a) == 0: return 'beer_servings' elif np.argmax(a) == 1: return 'spirit_servings' else: return 'wine_servings'
@NN-sw4io
@NN-sw4io 4 года назад
Hi Kevin, How to perform if then else in lambda dataframe? For example I want to convert number columns (Result1, Result2, Result3) to category ("Fail" / "Pass"). If x < 80 then Fail else Pass Thank you.
@ilyastrojnov7627
@ilyastrojnov7627 3 года назад
for simple operations like len and sum, no functions are needed, for example: df ['Len'] = df [Column_with_text] .str.len (), it will be much faster. To calculate the sum or average, we can choose an axis: df ['Total_for_rows'] = df.sum (axis = 0) or df.loc ['Total_for_columns'] = df.sum (axis = 1)
@gilberthor1988
@gilberthor1988 4 года назад
Congratulations for this video! I have one question: how can I, for exemple, get each string of the column "Name" and put them into a sigle list? For example: [Futrelle, Mr., Jaques, Health, Lily, May, Peel, Allen, Mr., William Henry]. Thanks in advance!
@HossainRabin
@HossainRabin 5 лет назад
Thanks Kevin, can u plz create deep learning tutorial series?
@dataschool
@dataschool 5 лет назад
Thanks for your suggestion!
@narudh
@narudh 4 года назад
i was hoping there was an easier way to access values in list / dicts stored the df. something like df['column'][list_index] :( i think the db['column'].apply(lambda x: x[list_index]) is a bit too annoying for me coming from SQL
@brendensong8000
@brendensong8000 3 года назад
Question... apply(np.argmax, axis=1) is not working for me. it just returns the same value as "apply(max, axis=1) method... It's now 2020, so I imagine the pandas library has changed. Do you know what is the alternative method that can return the max value for each of the row value? Thank you in advance.
@sinabaghaei3504
@sinabaghaei3504 3 года назад
drinks.loc[:, 'beer_servings':'wine_servings'].apply(np.argmax, axis=1) this line of code shows the result of column's names as their index like below 0 0 1 1 2 0 3 2 4 0 do you know why it doesn't show the name of the columns? Thanks in advance
@ravinduabeygunasekara833
@ravinduabeygunasekara833 Год назад
This is an awesome tutorial! LEarned a lot from this. One question, what if I want to create 2 new columns named "First Name", "Last Name" and then split the values in Name column into those 2. Ex:For 1 st row, the "First Name" = Mr. Owen Harris and "Last Name" = Braund. Could you share the workaround to get this done?
@ahe970
@ahe970 Год назад
Great - just curious when u wrote ur function get_element, it has 2 parameters: my_list and position. However, when u applied it, u only passed it position = 0. Is it because first parameter will come for the spilt Name? It seems awkward to me - can u please, explain. Also, the lambda function is very confusing to me can u please explain more or if u have a video for it, please, direct me
@fangyuancao5026
@fangyuancao5026 6 лет назад
Super helpful!
@dataschool
@dataschool 6 лет назад
Great!
@PriyaM-og6ji
@PriyaM-og6ji 3 года назад
great video sir!
@dataschool
@dataschool 3 года назад
Thanks!
@samc2481
@samc2481 6 лет назад
Best pandas tutorial so far on the internet... Thanks Kevin. Great work. hope you can do more tutorial on applied Tensorflow & ML
@dataschool
@dataschool 6 лет назад
Thanks for your kind comment, and also for your suggestion!
@yellowbug772
@yellowbug772 6 лет назад
Really appreciate it, thank you, Kevin!
@dataschool
@dataschool 6 лет назад
You're welcome!
@anandv.p5113
@anandv.p5113 2 года назад
How to extract a value from a data in many rows with a % or any other special character like %3.5 or %4.5 I want to extract these type of values from a data in different rows having different string length and in different positions. How can we extract this vlaues
@hongdekong
@hongdekong 3 года назад
Hi, I have a question. I am trying to add a column to a df with the map method. It works. Kinda ... It only copies the first part of the (quite long) string and leaves the rest of it out. The split occurs at a random point. Why is it not taking the whole strings into the dataframe?
@mygcoder
@mygcoder 2 года назад
Hi Kevin and thank you for this video series. I wanna ask you a question, I used np.argmax function, but it didn't give me the column names. It gave me the orders of the max columns. I checked many times, and I'm sure that I exactly write the codes as yours, and tried argmax with some other dataframes, always it gives me the order of the columns not the column names. Can you explain this, and how I get the names?
@sachindeshpande1
@sachindeshpande1 2 года назад
Yes, I am also facing same issue. Have you solved this problem?
@mygcoder
@mygcoder 2 года назад
@@sachindeshpande1 Yes I solved it. That is because of different versions. Kevin uses an old version. New versions are like what we faced.
@sachindeshpande1
@sachindeshpande1 2 года назад
@@mygcoder Thanks a lot, I thought so but not checked with old version.
@dataschool
@dataschool Год назад
Thanks for figuring it out!
@almirhasan682
@almirhasan682 4 года назад
my_list was not defined...how does pandas know that its the list, containing splitted names?...can someone enlighten me plz....
@alejandrozaizar1329
@alejandrozaizar1329 4 года назад
How would you find the best optimal cut off point for continuous variables having a binary outcome variable?
@hpchen5402
@hpchen5402 8 лет назад
This is a great video series on pandas. Really concise and clear. Many thanks for the effort!
@dataschool
@dataschool 8 лет назад
Thanks for your kind comment! I enjoyed creating the series :)
@anAlokDubey
@anAlokDubey 2 года назад
You are really a best teacher :-) your videos are very helpful and very informative. Thanks you so much 😊😊
@dataschool
@dataschool 2 года назад
Thank you! 🙏
@ol_k_p_87
@ol_k_p_87 2 года назад
Hi! Thanks a lot for video!!! On 8:54 u have a "Name" column with listed words. I have quiet the same, and i need to compare it to a set with unique values, than make a new column with matched value. Could U please help me out ))?
@boubacaramaiga4408
@boubacaramaiga4408 5 лет назад
Clear explanation, excellent tutoriel. Many thanks.
@dataschool
@dataschool 5 лет назад
You're very welcome!
@bhavyaa2726
@bhavyaa2726 3 года назад
How to use apply(len) for a cell while iterrows() . Actually I have a row and want to access length of a perticular column.
@sureshkumartwarakavivenkat6760
@sureshkumartwarakavivenkat6760 4 года назад
Very good explanation please run a case study from problem definition onwards
@mazali9899
@mazali9899 5 лет назад
Hi Kevin - thanks for your videos - really helpful. Could you please go through 'ColumnTransformer' - I believe OneHotEncoder is being deprecated in the latest version so categorical encoding will not be handled by sklearn ColumnTransformer. many thanks
@dataschool
@dataschool 5 лет назад
I actually recorded a 40-minute lesson on Pipeline, ColumnTransformer, and OneHotEncoder, but it's only for members of Data School Insiders. If you'd like to join at the $5 level, you can watch that lesson and 10 more hours of webcast recordings, in which I answer questions like that! Here's the master list of questions I've answered: www.patreon.com/posts/master-list-of-25133912 The 40-minute lesson is from the February 22 webcast.
@whatwasisaying1338
@whatwasisaying1338 4 года назад
I'm glad I found your videos! You make understanding these concepts much easier!
@dataschool
@dataschool 4 года назад
Thanks very much for your kind words!
@Leonardo-jv1ls
@Leonardo-jv1ls 3 года назад
why 1 is male and 0 female? Anyway. Thank you a lot for your videos. They are the best.
@allenrajiv
@allenrajiv 4 года назад
Hello How can i sum the values across the columns rather than down the columns. (like table across calculation in tableau)
@hyakushiki23
@hyakushiki23 5 лет назад
I just found your videos and they are awesome. Your explanations and examples are easy to understand, but also very practical. I am looking forward to watching the other 29 videos
@dataschool
@dataschool 5 лет назад
Great to hear!
@PaulHester66
@PaulHester66 7 лет назад
Thx for all the effort. I have a scenario I am struggling with though. I have a df with a series of locations represented by columns Latitude and Longitude (plus other data columns). I have a base station that the Lat/Long was recorded at, and that can be considered fixed for now, at, say lat 53.8, long -3.5. I wish to add 2 columns to my df. Angle and distance. For each row (lat/long position) I wish to add Angle from base station and distance. I have a function, getBearingDistance which takes 2 lat/longs and returns 2 values, distance and angle. How would I get that into two extra columns easily?
@dataschool
@dataschool 7 лет назад
Great question! I would probably loop through the rows using a for loop and the iterrows method, doing calculations and assigning the resulting values to new columns within the loop. (I would create the 2 new columns outside the loop and fill them with null values before entering the loop.) An example of iterrows is here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-B-r9VuK80dk.html
@jagjitsingh9045
@jagjitsingh9045 4 года назад
Hi, could you please me to append the two csv file in single files?
@dataschool
@dataschool 4 года назад
Perhaps you are looking for the "concat" function?
@jagjitsingh9045
@jagjitsingh9045 4 года назад
@@dataschool no... I just wanna to console to csv or excel files.
@dataschool
@dataschool 4 года назад
For CSV files: use a text editor, or pure Python code (not pandas).
@abdouliemanneh
@abdouliemanneh 2 года назад
After unidecode, how do I pass apply () to the elements in the column?
@aminasgharisooreh9243
@aminasgharisooreh9243 4 года назад
Thanks. it is a great series about DATA SCIENCE
@jundou7858
@jundou7858 6 лет назад
thanks for the tutorial, very helpful.
@dataschool
@dataschool 6 лет назад
You're very welcome!
@FormikFilms
@FormikFilms 2 года назад
Does anyone else have issues with the apply(np.argmax, axis=1) part? Instead of returning the names of the columns, the output returns the value of columns (its position). Could this be due to an update of python? My code is exactly the same as in the video
@bluecheese20401
@bluecheese20401 Год назад
Yep, 10 months after u I'm getting the same outcome.
@vlinkin22
@vlinkin22 5 лет назад
Nice, finally I understood the apply method Many Thanks !
@dataschool
@dataschool 4 года назад
Great to hear!
@samshah3667
@samshah3667 5 лет назад
Thanks for the great videos. I just finished watching all the 30 videos in this series and enjoyed learning Pandas. You are a great teacher! I also signed up for the newsletter. I have a question and hope that despite your busy schedule, you can either answer me, or at least point me to the right direction: How would I add a column to a data frame, which holds aggregate data from the same dataframe? Let's say I have a dataset of "expenses" over the last 5 years. I want to add two columns to the dataset, and for every row, the first column will hold the "year to date" sum of all expenses (including this one), from the beginning of the year, and the second column will hold the "month to date" sum of all expenses. How can I accomplish this? Thanks!
@dataschool
@dataschool 5 лет назад
Thanks so much for watching the videos, and for your kind words! Regarding your question, I feel like it's possible but I'm not sure exactly how. If you are interested in joining Data School Insiders, you could post this question in our private forum and see if someone happens to know: www.patreon.com/dataschool
@faizraina7946
@faizraina7946 Год назад
can someone please tell me why at 13:23 ,axis = 1 is for rows . zero is for row and 1 is for columns i guess
@sandhya_exploresfoodandlife
@sandhya_exploresfoodandlife 5 лет назад
hi - Thanks so much for this! i have a question.. how would you use the apply function on two columns at the same time?
@19aavila
@19aavila 5 лет назад
with applymap(), it's at the end of the video :)
@alexsandroignacio761
@alexsandroignacio761 3 года назад
Very nice teachers i ever seen.
@dataschool
@dataschool 3 года назад
Thank you!
@KumarGaurav-pf4bs
@KumarGaurav-pf4bs 4 года назад
Can you please share how to use for loops in python pandas in detailed, Like how we create multiple calculated columns with different different columns in dataframe?
@RishankKumar
@RishankKumar 4 года назад
what if I want a new column called location and it should contain name of those countries where beer_servings > 100 and wine_servings>100, if condition is not met then name in location column should be "antartica"
@dataschool
@dataschool 4 года назад
You'll use a combination of filtering by multiple conditions, loc, and assignment statements. Hard for me to give the exact code without trying it out. Hope that helps!
@alirezanooraei4055
@alirezanooraei4055 5 лет назад
this was great!
@dataschool
@dataschool 5 лет назад
Thanks!
Далее
How do I use the MultiIndex in pandas?
25:01
Просмотров 174 тыс.
Python Pandas Lambda Function Tutorial With EXAMPLES
12:58
БАГ ЕЩЕ РАБОТАЕТ?
00:26
Просмотров 122 тыс.
Learning Pandas for Data Analysis? Start Here.
22:50
Просмотров 102 тыс.
How do I make my pandas DataFrame smaller and faster?
19:06
Pandas Functions: Apply vs. Map vs. Applymap
11:53
Просмотров 26 тыс.
Make Your Pandas Code Lightning Fast
10:38
Просмотров 184 тыс.
Pandas functions: merge vs. join vs. concat
16:15
Просмотров 26 тыс.
Speed Up Your Pandas Dataframes
11:15
Просмотров 71 тыс.
What do I need to know about the pandas index? (Part 1)
13:37
БАГ ЕЩЕ РАБОТАЕТ?
00:26
Просмотров 122 тыс.