Question: ```
If the data frames are as follows :
df1
column names = UniqueID  Age Gender
values = 213,21,F
         145,34,M
         890,23,F
df2
column names = ID Occupation Bill
               145 Teacher 45RS
               890 Student 70RS 
               456 Teacher 90Rs

```

I want to use a function which finds the common values in "UniqueID" from df1 and "ID" from df2 and gets stored in df3. Also, the only columns which exist in df3 should be of "common ids" and the columns of df2.

Answer: 
You can use [pandas.merge()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html) to get the common rows based on the columns. Try this:

```
df3 = pd.merge(df1, df2, how='inner', left_on='UniqueID', right_on='ID')

```

However, this will give you all the columns. After that you can use 

```
df3.drop([column_names], inplace=True)

```

to drop the columns that are not required.
```
df3 = df1[df['series_name'].isin(df2['series_name'])]

```

**EDIT:**

Adding details per request. This simple approach can compare across 2 different dataframes, placing the output in a third.