Instagram
youtube
Facebook
Twitter

Inner Merge

Working Multiple DataFrames

  • We frequently distribute relevant data across several tables in order to store it effectively.
  • For this tutorial, we will be using some datasets from an e-commerce business and we have three datasets namely Sales and Targets.
  • Let's check our datasets to get familiar with them.
    import pandas as pd
    
    sales = pd.read_csv('sales.csv')
    targets = pd.read_csv('targets.csv')
    print(sales.head())
    print(targets.head())


Inner Merge

  • In Pandas, we can merge two tables using merge() function and the merge function will look for the common column.
    sales_vs_targets = pd.merge(sales, targets)
    print(sales_vs_targets)
  • We can also merge them in this way too:
    new_df = sales.merge(targets)

    Which is the same as used in the above code demonstration.

  • In our table, we can also retrieve specific rows based on the condition we gave. For example, we are going to get only those rows from our new_df in which revenue > target

    n = new_df[new_df.revenue >= new_df.target]
    print(n)