I am having two dataframes df1& df2 as below.
import pandas as pd
data1 = [['1', 11], ['2', 12], ['3', 13],['5', 18],['8', 19]]
df1 = pd.DataFrame(data1, columns=['Strike', 'Price'])
df1
Output-
Strike Price
0 1 11
1 2 12
2 3 13
3 5 18
4 8 19
data2 = [['1', 10], ['2', 15], ['4', 14],['8', 18]]
df2 = pd.DataFrame(data2, columns=['Strike', 'Price'])
df2
Strike Price
0 1 10
1 2 15
2 4 14
3 8 18
I want to compare column Strike of df1 & df2 and keep only rows which are having comman values present in Strike column of both df1,df2 and reset index of both dataframes.
Expected Output-
df1
Strike Price
0 1 11
1 2 12
2 8 19
df2
Strike Price
0 1 10
1 2 15
2 8 18