Тёмный

Find the Min and Max Values for Rows and Columns - Pandas 

Chart Explorers
Подписаться 11 тыс.
Просмотров 22 тыс.
50% 1

In this video we review how to find the minimum and maximum values for rows and columns in a pandas DataFrame.
We also discuss how to find the min and max values of a specific row or column (i.e., find the min and max values in a pandas Series).
Sometimes we want want the index location instead of the actual value. Don't worry, this video covers how to find the index location of the min and max values as well.
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
$15 off Annual Dataquest subscription
app.dataquest.io/referral-signup/qybqz3r8/
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Did you find this video helpful? Consider subscribing for weekly tips, tricks, and tutorials.
/ @chartexplorers
Other Helpful Videos:
Convert pandas columns and rows to numeric values: • CHANGE COLUMN DTYPE | ...
0:00 Intro
0:15 Setup
0:59 Column Max
1:38 Column Min
1:56 Specific Col
2:14 Row Max
2:42 Row Min
2:53 Specific Row
3:46 Index Location
4:24 Conclusion

Наука

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

 

6 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@shervintheprodigy6402
@shervintheprodigy6402 3 года назад
Thank you!!! I am 12 years old and I am making a heart disease predictor!!! This video helps me a lot!!!
@ChartExplorers
@ChartExplorers 3 года назад
That's amazing! Let me know if there is anything I can do to help :)
@shresththakur5344
@shresththakur5344 3 года назад
I am completing my project on the last day and this helped me immensely, thank you so much!
@ChartExplorers
@ChartExplorers 3 года назад
I'm glad! I hope you finish, good luck!
@chayanbanerjea3271
@chayanbanerjea3271 3 года назад
Thank you!
@elijonam1
@elijonam1 2 года назад
thanks for your useful video. I'm wondering how I can get max for a specific column after every nth row in pandas? let's say max of column 3 every 3months
@user-tb8fg2lu3g
@user-tb8fg2lu3g 6 месяцев назад
i have a project with a large data set and was wonder how could i find the avrage of multiple columns
@krisztiankovacs5221
@krisztiankovacs5221 2 года назад
How would you find the max value in specific rows? For example I want to know the max and min of col_2,col_3,col_4 for every month and create a new column with those values. I tried about twenty different things but can't seem to get the syntax right :(
@kondareddy5471
@kondareddy5471 2 года назад
In a data set we have city column consist of 5 different cities like new york ,Texas and in other column total charges how to get mininum and maximum charges of particular city
@federicogonzalez7673
@federicogonzalez7673 3 года назад
Cool. Suscribed
@ChartExplorers
@ChartExplorers 3 года назад
Thanks @Federico Gonzalez
@ingridarellano2402
@ingridarellano2402 3 года назад
Hi I wanted to thank you for sharing your knowledge that is helping me a lot, I have a question and I hope you can help please. When you find the max_index, in the result you get the name of the months, how could I get one more column with the numerical result, this is my question, if you could help me, please.
@ChartExplorers
@ChartExplorers 3 года назад
Hi Ingrid, great question. What you can do is use .max with a boolean mask (more info on boolean masks in this video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ni9ng4Jy3Z8.html @1:19). If we wanted the index position and value for Col_1 we can use the following df[df['Col_1'] == df['Col_1'].max()]['Col_1'] To explain, We want to return a dataframe df[ ] We want the dataframe to include only rows where Col_1 is the max value df['Col_1'] == df['Col_1'].max() and we only want to return Col_1 not all the columns ['Col_1'] Put it all together and we get df[df['Col_1'] == df['Col_1'].max()]['Col_1'] this will return a Series with the index position of the max value and the max value :)
@hugoalvarado9347
@hugoalvarado9347 2 года назад
Someone knows how to find the 5 mínimum values in a data frame (Column or row)?
@jives.
@jives. 3 года назад
thanks.
@ChartExplorers
@ChartExplorers 3 года назад
You're Welcome!!
@mikeyg8631
@mikeyg8631 3 года назад
Really like this video, simple to understand. Am new to python, trying solve a project. Say df similar to above example, I would like to determine that for Col_1, the latest value of 56 is largest since Nov, Col_2 72 is largest since Jul, Col_3 42 is smallest since Nov, Col_4 59 largest since Sep and Col_5 31 largest since Nov. What would be the fastest way to do it, specially for thousands of data points? thanks!
@ChartExplorers
@ChartExplorers 3 года назад
Hi @MikeyG, good question. I want to make sure I'm understanding it correctly. You want to determine if the most recent value (the December value) is the largest value from a certain point (Nov, Jul, Nov, Sept). How are you selecting that point (in the example the month Nov, July, Nov, Sept). Understanding this will help me better answer the question.
@mikeyg8631
@mikeyg8631 3 года назад
@@ChartExplorers Trying to compare the latest values, if it is highest/lowest since what time period. Col_1 56 is largest since Nov as 80 in Oct is larger than 56, so stop the comparison there. Col_2 72 is largest value since Jul as the Jun value of 78 is larger than latest, stop comparison there. Col_3 42 is smallest value since Nov as Oct value of 32 is smaller so stop comparison there. and so on. Hope this is clear? Thank you!
@ChartExplorers
@ChartExplorers 3 года назад
@@mikeyg8631 How are you determinig the time period?
@mikeyg8631
@mikeyg8631 3 года назад
@@ChartExplorers Apologies for not explaining this clearly, I'll try again. For each Col, compare the latest value (Dec) with the previous (Nov). If equal, then done. If < than, then continue comparing to the next previous values while < than. If it becomes >=, stop comparison and get the index at the position where it was last < than. The same if Dec > Nov, keep comparing to previous while > than, stop when it becomes than. Not sure if a While loop would be appropriate/fastest? Thanks!
@mikeyg8631
@mikeyg8631 3 года назад
@@ChartExplorers Would you mind taking a look at this def I put together please using the df example on the video. When I do df.apply(checkperiod), I want to be able to output the Col_x name with the corresponding result, but am a bit lost - I'm getting the result I need then the Col names below and says None. Also, do you have any suggestions if there is anything faster that this, specially with thousands of rows? Thank you! def checkperiod(df):
@ultimategamer7859
@ultimategamer7859 3 года назад
how do i find the max and the min for the last 5 rows of a df? thank you
@ChartExplorers
@ChartExplorers 3 года назад
Hi Ultimate Gamer, If you are looking for the min or max of last 5 rows of a specific column of a df df['col_name'][-5:].min() df['col_name'][-5:].max() if you want the min / max of last 5 rows of all numeric columns of df: df[-5:].min() df[-5:].max() if you want the min/max of of last 5 rows of numeric values of df (return the minimum of entire df) df[-5:].min().min() df[-5:].max().max()
@ultimategamer7859
@ultimategamer7859 3 года назад
@@ChartExplorers thanks boss. ur acc a legend.
@netoremining8114
@netoremining8114 2 года назад
what if they are even? i have some that are even :(
@harsinchh4342
@harsinchh4342 Год назад
Sir, A B C 20 40 30 (10) 50 [60 20 30 20 50 10 10 60 10 80 30 (90) 50] 20 20 70 From column A min value 10 to column b max value 90, how can I sum column c all cells from min value to max value at column A to column B.
@Douken
@Douken 2 года назад
What if the numbers are above 100000000 ?
@ChartExplorers
@ChartExplorers 2 года назад
If you have values over 1 billion you can still use the same methods. In my example I just used values that were less than 100 because otherwise it harder to see what is going on with the example. Are you running into issues?
Далее
How to compare columns in pandas
2:06
Просмотров 17 тыс.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Happy 4th of July 😂
00:12
Просмотров 11 млн
How to filter a pandas DataFrame | 6 HELPFUL METHODS
17:27
Loop / Iterate over pandas DataFrame (2020)
11:05
Просмотров 80 тыс.
Pandas Functions: Apply vs. Map vs. Applymap
11:53
Просмотров 24 тыс.
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
Просмотров 172 тыс.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00