Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Week Day w/ PD

Why when using the below code, I get values 6,0,1,2,3 for week days versus the expected 0 (Mon), 1, 2, 3, 4 (Fr)? Where 6 = Monday versus Sunday which the PD documentation says it should be?

e_time = pd.Timestamp(get_datetime()).tz_convert('US/Eastern') 

print e_time.weekday()  
3 responses

If you are running with daily data backtest, then times are for midnight UTC each day, so converting it to US/Eastern is going to give you funny results. If you're using minutely data, I'm not sure why that might be -- post a backtest which shows it happening?

Just some thoughts.

This is a bug and it needs to be fixed.

e_time = pd.Timestamp(get_datetime()).tz_convert('US/Eastern') 

print e_time.weekday()  

2015-03-17PRINT0
2015-03-18PRINT1
2015-03-19PRINT2
2015-03-20PRINT3
2015-03-23PRINT6
2015-03-24PRINT0
2015-03-25PRINT1
2015-03-26PRINT2
2015-03-27PRINT3
2015-03-30PRINT6
2015-03-31PRINT0
2015-04-01PRINT1
2015-04-02PRINT2
2015-04-06PRINT6
2015-04-07PRINT0
2015-04-08PRINT1
2015-04-09PRINT2
2015-04-10PRINT3
2015-04-13PRINT6
2015-04-14PRINT0
2015-04-15PRINT1
2015-04-16PRINT2
2015-04-17PRINT3
2015-04-20PRINT6
2015-04-21PRINT0
2015-04-22PRINT1
2015-04-23PRINT2

weekday The day of the week with Monday=0, Sunday=6

More likely 6 refers to the Monday, which was time stamped midnight the morning of in UTC, which then got rolled back to 7/8pm Eastern on Sunday by the timezone application.