i am prettys new to Python and trying to do an event analysis. I have two datasets: One with events and one with stockdata. Now i need to construct equally weighted portfolios and 'refresh' the portfolio construction every month. Therfor I need consistent data (i guess). I mean for every date i need stock prices for all stocks which are in this analysis. No I wanted to filter the data in this way that it shows me the biggest 'cluster' where i have data for all stocks for a certain period of time. As alternative show me all stocks and the period of time which have data. I hope you guys understand my explanation.
import pandas_datareader as pdr
import pandas as pd
import numpy as np
from sklearn import linear_model
import scipy.stats as st
d = {'Date': ['1.02.2019', '2.02.2019', '3.02.2019', '4.02.2019', '5.02.2019'],
'a': [3.6, 3.4, 4.1, 4.2, 4.3],
'b': ['',2.4, 2.5, 2.6, 2.5],
'c': [2.5, 2.4,'',2.5, 2.5],
'd': [2.3, 2.4, 2.4, 2.5, '']}
df = pd.DataFrame(data=d)
df.set_index('Date')
In this case it should give me either a,b from 2.5.2019 to 5.02.2019 or a,d from 1.05.2019 to 4.5.2019 or something like this.
Is there a forumla for this in pandas?
Thx in advance