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

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

ความคิดเห็น • 33

  • @shervintheprodigy6402
    @shervintheprodigy6402 3 ปีที่แล้ว +9

    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 ปีที่แล้ว +1

    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 ปีที่แล้ว +2

    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

  • @ingridarellano2402
    @ingridarellano2402 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Hi Ingrid, great question. What you can do is use .max with a boolean mask (more info on boolean masks in this video th-cam.com/video/ni9ng4Jy3Z8/w-d-xo.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 :)

  • @CleoWaterDevelopment
    @CleoWaterDevelopment 10 หลายเดือนก่อน

    i have a project with a large data set and was wonder how could i find the avrage of multiple columns

  • @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

  • @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 :(

  • @mikeyg8631
    @mikeyg8631 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      @@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):

  • @federicogonzalez7673
    @federicogonzalez7673 3 ปีที่แล้ว +1

    Cool. Suscribed

  • @HugoRSCC
    @HugoRSCC 3 ปีที่แล้ว

    Someone knows how to find the 5 mínimum values in a data frame (Column or row)?

  • @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 ปีที่แล้ว +1

      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.

  • @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.

  • @jives.
    @jives. 3 ปีที่แล้ว +1

    thanks.

  • @netoremining8114
    @netoremining8114 2 ปีที่แล้ว

    what if they are even? i have some that are even :(

  • @Douken
    @Douken 3 ปีที่แล้ว

    What if the numbers are above 100000000 ?

    • @ChartExplorers
      @ChartExplorers  3 ปีที่แล้ว

      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?