0

I've been trying to get the intersection points of 2 DataFrame columns containing a stock dataset with 87 rows. As you can see in this sample plot:

sns plot sample

I want to retrieve the intersection points between the Close values and the 10 days MA (Moving Average) values, NOT the common ones, the points where both graphs cross each other.

The piece of code I am using to retrieve the DataFrame is as it follows:

import pandas_datareader as pdr
import matplotlib.pyplot as plt
import seaborn as sns

sns.set_style('whitespace')

dataset = pdr.get_data_yahoo('AAPL', start='2018-07-20')
dataset.dropna(inplace=True)
dataset = dataset[['Open', 'High', 'Low', 'Close']]

dataset['10 days MA'] = dataset['Close'].rolling(window=10, center=False).mean()

dataset[['Close', '10 days MA']].plot(subplots=False, figsize=(12, 5))
plt.show()

What I want to do is get and plot the intersection points of dataset['Close'] and dataset['10 days MA'].

Any help provided will be grateful! Thank you!

alvarobartt
  • 453
  • 5
  • 15
  • 1
    Possible duplicate of [Python - matplotlib: find intersection of lineplots](https://stackoverflow.com/questions/8094374/python-matplotlib-find-intersection-of-lineplots) – SpghttCd Nov 21 '18 at 18:50
  • Share some sample dataset. – min2bro Nov 22 '18 at 03:43

0 Answers0