I'm new to python/pandas and I had a question of merging two dataframes together.
Consider I had
df1:
Portfolio Value
Date
2016-07-01 100000
2016-07-08 100005
2016-07-15 100010
2016-07-22 100015
2016-07-29 100020
2016-08-05 100025
2016-08-12 100030
2016-08-19 100035
2016-08-26 100040
2016-09-02 100045
2016-09-09 100050
2016-09-16 100055
2016-09-23 100060
2016-09-30 100065
2016-10-07 100070
2016-10-14 100075
2016-10-21 100080
and
df2:
Portfolio Value
0 100015
1 100030
2 100040
3 100075
I would like to result in a dataframe that keeps the values and date of df1
that also exists in df2
as shown below:
newdf:
Portfolio Value
Date
2016-07-22 100015
2016-08-12 100030
2016-08-26 100040
2016-10-14 100075
I believe that this a merge, but I am not certain. If any other implementation would be better that is fine as well.
Any tips would be greatly appreciated!
Edit
an inner join was attempted as shown in the possible duplicate by the first comment but it does not keep the date index. Is there a way to get the dates with the Portfolio Values to show as well?