1

Dictionary name = tum4 Example of DataFrame name in 'tum4' dictionary: ES0001

1)How do I count the number of rows in all dataframes in 'tum4' dictionary?

2)How do I count the number of rows in a specific dataframe in 'tum4' dictionary?

I tried:

1)Haven't got a clue

2)len(tum4['ES0001'])

not_speshal
  • 22,093
  • 2
  • 15
  • 30
SData11
  • 11
  • 1
  • Does this answer your question? [How do I get the row count of a Pandas DataFrame?](https://stackoverflow.com/questions/15943769/how-do-i-get-the-row-count-of-a-pandas-dataframe) – jared_mamrot Jul 30 '23 at 23:32

1 Answers1

1
  1. How do I count the number of rows in all dataframes in 'tum4' dictionary?
out = sum(df.shape[0] for df in tum4.values())

# or
out = sum(map(len, tum4.values()))
  1. How do I count the number of rows in a specific dataframe in 'tum4'
out = tum4['specific_name'].shape[0]

# or
out = len(tum4['specific_name'])

Also refer to this classical Q/A

mozway
  • 194,879
  • 13
  • 39
  • 75
  • Thank you so much mozway, regarding 1) do you know how I can get a list of the row count of every dataframe in the tum4 dictionary? – SData11 Jul 26 '23 at 11:44
  • This is basic python, you should read on list/dictionary comprehensions ;) I'd use `{k: len(df) for k, df in tum4.values()}` – mozway Jul 26 '23 at 11:46