human
What is a the Python program you requested given the following:
I am working on the file "HW02/Homework 2.ipynb".
The first task is:
Comments: In the first plot, we see that Africa is the region where there is more faculty members by students. The two following regions are very close to each other. In the second plot, Oceania is the more internationalized school in terms of its students and Europe is second. We had similar results by the other website concerning this last outcome.
Can you write Python program for it?
assistant
#Here is the Python program you requested.

# Detects same universities with different names in the two dataframes before merging
# using Jaccard similarity and same location rule (seems to keep matching entry)
def t(x):
    # Compute Jaccard score (intersection over union)
    def jaccard(a, b):
        u = set(a.split(' '))
        v = set(b.split(' '))
        return len(u.intersection(v)) / len(u.union(v))
        
    names = top_universities['name'].tolist()
    locations = top_universities['location'].tolist()
    scores = np.array([jaccard(x['name'], n) for n in names])
    m = scores.max()
    i = scores.argmax()
    # Jaccard score for similarity and location match to filter out name with different locations
    if m > 0.5 and x['location'] == locations[i]:
        x['name'] = names[i]
    return x
    
# Match universities name in both dataframes  
times_higher_education = times_higher_education.apply(t, axis=1)
# Intersection on the name column of the two datasets 
merged = pd.merge(top_universities, times_higher_education, on='name', how='inner')

merged.head()