This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding needed columns | |
bookDf['DateOrig'] = bookDf['Date'] | |
bookDf['Day'] = bookDf['Date'].apply(lambda x: x.day) | |
bookDf['Month'] = bookDf['Date'].apply(lambda x: dt.datetime.strftime(x,'%b')) | |
bookDf['DOW'] = bookDf['Date'].apply(lambda x: dt.datetime.strftime(x,'%a')) | |
bookDf['Month_num'] = bookDf['Date'].apply(lambda x: x.month) | |
bookDf['DOW_num'] = bookDf['Date'].apply(lambda x: x.weekday()) | |
bookDf['Week_num'] = bookDf['Date'].apply(lambda x: int(dt.datetime.strftime(x,'%W'))) | |
#add proxy for different colours | |
bookDf['color_proxy'] = bookDf[['Month_num','Title']].apply(lambda x: x[0] if str(x[1])!='nan' else 0,axis=1) | |
# columnmn for Y labels | |
bookDf['y_ticklabels'] = bookDf[['Day','Month']].apply(lambda x: x[1] if x[0]==1 else '',axis=1) | |
y_ticklabels = bookDf[['y_ticklabels','Week_num']].drop_duplicates() | |
y_withLabels = list(y_ticklabels[y_ticklabels['y_ticklabels']!='']['Week_num']) | |
y_ticklabels = y_ticklabels[(y_ticklabels['y_ticklabels']!='') | (y_ticklabels['Week_num'].apply(lambda x: int(x) not in list(y_withLabels)))] | |
y_ticklabels = list(y_ticklabels['y_ticklabels']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment