I am learning to use pandas and python. I want to look up a value from an excel in column A and print the value in column B. But Pandas can't find my value. Sometimes Pandas can find my value, but sometimes Pandas can't find my value, even though it is the correct value and is in the excel.
I make a syntax like this:
import pandas as pd
TARGET = "88807"
data = pd.read_excel('myexcel.xlsx')
row = data.loc[data['KOLOM_A'] == TARGET]
if row.empty:
print("DATA NOT FOUND IN THE DATABASE.")
else:
KOLOM_B = row.iloc[0]['KOLOM_B']
print(KOLOM_B)
KOLOM A | KOLOM B |
---|---|
54981 | AGUS |
88807 | BUDI |
86454 | CAHYO |
86280 | DORI |
Sometimes the data shows results but sometimes doesnt.
I think the problem on KOLOM A, data is TEXT or Number. But i already convert to Text and also to Number and still have same promblem. Please Help Me.