Issue
In My excel other columns having values if column 'A' will have values till 8 row means it will not be the same when we refer other columns 'D' OR 'E' I want to find last row of particular column. Because I need to use the number in for loop range. Kindly help
i found many answers but all are calculating if any column contains value also it will give that number. I used below
last_empty_row=len(sheet_obj['G'])+1
but it gives same result as
row=sheet_obj.max_row
This is not a duplicate question.
I do not know how it will be below link accepted answer for my question.
How to find the last row in a column using openpyxl normal workbook?
ws.max_row len(ws['A'])
will give same answer this is not the answer i am loooking for. What i am looking for is below accepted answer is correct one find last row in particular column.
Solution
Perhaps this works:
df['G'].notna().sum()
Example:
import pandas as pd
df = pd.read_excel('test.xlsx')
df['A'].notna().sum()
result: 3
df['A'].notna().sum()
result: 1
Answered By - keramat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.