Sorted in alphabetical order of month.Seems to be default.To get sorted by date…got to use sort_index

Hi, I am also getting the same result despite being Sunday is a non working day for the stock market then how the mean can be computed for the 6th weekday ?

Can anyone help ?

For problem 6 (#On the days in which NIFTY50 closed higher than the open, what was the mean of(close-open)for NIFTYNext50), this is what i have done. can anyone confirm if this is correct? i am getting mean as 118.70188679245271

def difference(x):

if ((x.NIFTY50.Close - x.NIFTY50.Open) > 0):

return True

else:

return False

df5[‘NIFTY50’,‘Diff’] = df5.apply(difference, axis=1)

df5[‘NIFTYNEXT50’,‘Diff1’] = (df5.NIFTYNEXT50.Close) - (df5.NIFTYNEXT50.Open)

df5 = df5.sort_index(axis=1)

df_5 = df5[(df5.NIFTY50.Diff) == True]

df_5.NIFTYNEXT50.Diff1.mean()

problem[8]:

#In 2019, on how many days did the day’s close exceed the 30 day moving average in NIFTY50(exclude first month) and i am getting answer as follows. can someone confirm if this is correct?

df2[‘MA’]= df2[‘Close’].rolling(window=30).mean()

df2[‘Close_MA’] = df2[‘Close’] > df2[‘MA’]

df2.groupby(‘Close_MA’)[‘Close_MA’].count()

Close_MA

False 160

True 85

Name: Close_MA, dtype: int64

There are several post above you can refer for solution to 8.

My soln: Solutions for Week 10 Pandas FDS

Hey

Refer to my notebook on GitHub for solution of final problem and please contribute with better code or any error correction if noticed.

GitHub Link : https://github.com/sahilbansal1729/python-case-studies/blob/master/NIFTY%20Case%20Study%202.ipynb

Unable to find the GitHub page