Plot certain days only pandas dataframe

Viewed 809

trying to get better at using Python and pandas...

I have some stock market data, I have added a day_of_week column(Monday, Tuesday, Wednesday, Thursday, Friday) based on the "Date" columnn, obviously theres Open, High, Low and Close columns as well for each day, and I've also added and pct-chance column, now what I want to do is print out, then plot the pct-change for all the Monday's, or whichever day I like, then I want to plot the average pct-change in a histogram style for each week day in my data, so it'll look like a histogram chart with Monday,Tuesday etc. along the X axis on the bottom, with their average pct-change data on the Y.

So somehow I need to figure out if day_of_week column == "Monday" return pct-change? But I'm assuming there's a better way with pandas somehow, with .loc or something but I can't figure it out :(

The data is indexed by just an integer, then a Date, O,H,L,C, Volume, Range, Pct_change, day_of_week columns etc, below is my output from data.head()

   Date     Open     High      Low   Settle   Volume  \
0 2017-07-20  12493.0  12567.0  12381.0  12422.0  94966.0
1 2017-07-19  12446.5  12481.5  12408.0  12432.5  68435.0
2 2017-07-18  12554.0  12569.0  12373.5  12425.5  96933.0
3 2017-07-17  12646.5  12668.0  12531.0  12587.0  65648.0
4 2017-07-14  12642.5  12658.5  12567.0  12611.0  59074.0

   Prev. Day Open Interest day_of_week  Range   < MR   > MR  Pct_change
0                 151217.0    Thursday  186.0    NaN  186.0   -0.568318
1                 148249.0   Wednesday   73.5   73.5    NaN   -0.112481
2                 154485.0     Tuesday  195.5    NaN  195.5   -1.023578
3                 145445.0      Monday  137.0  137.0    NaN   -0.470486
4                 144704.0      Friday   91.5   91.5    NaN   -0.249160

Hope someone can help/point me in the right direction, thanks!!

1 Answers
Related