I have a code in python like this :
merged_df = pd.merge(df1, df2, on='GCIF_NO', how='left')
def TAB_Online(row):
if pd.isnull(row['GCIF_NO']):
return 0
else:
return 1
and then after that i build a code like this :
df1['TAB_Online'] = merged_df.apply(TAB_Online)
but it return an error like this :
KeyError: 'GCIF_NO'
after that i check whether GCIF_NO available or not on the dataframe with a code like this :
# Example check to verify column existence
if 'GCIF_NO' in df1.columns:
print("Column 'GCIF_NO' exists in df1")
else:
print("Column 'GCIF_NO' does not exist in df1")
and it return Column ‘GCIF_NO’ exists in df1.
so where’s my problem?