问题
Here I grab the name and zip values from a different document; and store in variables: (works fine)
Name = find_name.group(0)
Then I simply want to search my excel file to find a match; where the Name text value is found, get row number(s):
data = pd.read_excel(config.Excel2)
row_number = data[data['Member Name'].str.contains(Name)].index.min()
print(row_number)
The above outputs the incorrect row number when printed, I cannot understand why. i.e. It does not print the row where the matching text value is found within my excel document. It prints an erroneous row number, that doesn't match the Name.
Then, I have tried something like this; but this doesn't output anything at all: (outputs Key Error)
idx = data[data['Member Name'].str.contains(Name)].index
row_number = idx[0] if len(idx)>0 else None
print(row_number)
Any thoughts on how to achieve this?
My excel looks as follows (with about 11000 rows like the below, and 8 columns).
A
1 | Member Name | Member Address Line 1 | Member Address Line 2
RHONDA GILBERT ADDRESS PT 1 ADDRESS PT 2 W/ ZIP
来源:https://stackoverflow.com/questions/57255266/search-excel-columns-for-matching-text-value-print-row-s