Untitled
unknown
plain_text
2 years ago
549 B
3
Indexable
import pandas as pd # Create the two dataframes d1 = pd.DataFrame({'name': ['JOHN1', 'DAVE', 'AJAY', 'TRACY', 'TIYA'], 'height': [174, 190, 184, 170, 162]}) d2 = pd.DataFrame({'name': ['john', 'dave', 'ajay', 'tracy', 'tiya'], 'weight': [70, 82, 65, 62, 53]}) # Convert the names to lowercase for consistency d1['name'] = d1['name'].str.lower() d2['name'] = d2['name'].str.lower() # Merge the dataframes based on the 'name' column df = pd.merge(d1, d2, on='name') # Print the resulting dataframe print(df)
Editor is loading...