Dec-16-2020, 08:42 PM
I'm trying to create a stock chart but with date on the x-axis, it's a black blur because the dataframe has 3407 entries.
So... what I'm thinking of doing is creating a new df column that has entries every n rows to allow it to be seen.
I tried this:
What happened? With the if condition being executed initially, why was the else condition executed when included? And why was execution done every row rather than every 5th row per the i%5 line?
Thanks!
So... what I'm thinking of doing is creating a new df column that has entries every n rows to allow it to be seen.
I tried this:
ES_skel = ES.drop(['Open','High','Low','Vol'],axis=1) ES_skel.index = ES_skel["Date"].apply(lambda x: pd.Timestamp(x)) for i in range(len(ES_skel)): if i%5 == 0: ES_skel["Month_Year"] = ES_skel.Date #ES_skel.index.strftime('%Y-%m') print(ES_skel.head(15))This resulted in the new Month_Year column being populated with the date for every row. Adding this else clause:
else: ES_skel["Month_Year"] = Noneresulted in None for every row in the new Month_Year column.
What happened? With the if condition being executed initially, why was the else condition executed when included? And why was execution done every row rather than every 5th row per the i%5 line?
Thanks!