I was trying to open a csv file panda_try.csv. What i want to do is to compare the elements in the first two columns from the file and check if they are equal. If they are equal, I want to append it in a list called selfloop_appender and then calculate the length of list. But when i try to `print (selfloop_appender)', i donot get any output and error. Any help will be great.
import pandas as pd
df = pd.read_csv('/home/venkat/Desktop/panda_try.csv')
xy_data = df.iloc[:,0:2]
def self_loops(xy_data):
selfloop_appender = []
for i,j in xy_data:
if i == j:
selfloop_appender.append([i,j])
print("the number of self_loops are:") + len(str(selfloop_appender))
return selfloop_appender
self_loops(xy_data)