Home > Enterprise >  How to count cells in a specific range with Pandas in python?
How to count cells in a specific range with Pandas in python?

Time:02-24

For example, I want to count the filled cells in the range C5 to C25 or D8 to D17. I can't use header names.

How can I do that?

dataxls = pd.read_excel('Racklist.xlsx', header=None)

CodePudding user response:

You can try:

 dataxls = pd.read_excel("YOUR_FILE_NAME.xlsx", 'Sheet1',  usecols = "C", header = 4, nrows=25)
 num_filled_cells = dataxls.shape[0] - dataxls.isnull().sum().values[0]
 print(num_filled_cells)
  • Related