0

So I have a list of dataframes and I want to get the max and min from it.

I know we have functions max() and min(), but how would I use that with panda's dataframes? I have a column with time that I want the min and maxes of.

For example, here's a list of dataframes

>>> df_list
[  letter  number animal
0      c       3    cow
1      d       4  mouse,   letter  number animal
0      f       1    cow]

To get the minimum I tried doing

>>> for df in df_list:
...     df['number'].min()
...
3
1

But as you can see it prints the minimum for two separate dataframes, I want just one minimum from the set of all the dataframes. How would I go about doing this, preferably without a loop if possible? Thanks!

  • dataframe also has a max() and a min(), your question lacks clarity – anky May 21 '21 at 16:37
  • @anky Help me and tell me what's unclear about it. I have a list of dataframes, how do I get the min and max from it? – ManWithTheQuestions May 21 '21 at 16:40
  • What have you tried and where are you stuck? did you look at the documentation for df.min() and df.max()? iterate through your list and get the values. If you fail let us know., check [how to create a good example for pandas](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples), please also read about [mcve](https://stackoverflow.com/help/minimal-reproducible-example) – anky May 21 '21 at 16:41
  • @anky Okay I added more information, does it help you? – ManWithTheQuestions May 21 '21 at 17:21
  • 1
    `min([df['number'].min() for df in df_list)])` ? – anky May 21 '21 at 17:23
  • @anky Great, thank you. – ManWithTheQuestions May 21 '21 at 17:37

0 Answers0