Pandas converts list of datetime values incorrectly
Question: I have a list of datetime values, and would like to convert the list into a
pandas.Series instance. The code boils down to the following:

    
    
    from datetime import datetime
    from datetime import timedelta
    from dateutil import parser
    
    day = parser.parse('2016-08-07T00:00:00Z')
    dates = [day + timedelta(days=delta) for delta in range(80)]
    
    pandas.Series(dates)
    

What puzzles me is that the code above returned lots of datetime instance of
1970-01-01:

    
    
    0    2016-08-07 00:00:00+00:00
    1    1970-01-01 00:00:00+00:00
    2    1970-01-01 00:00:00+00:00
    3    1970-01-01 00:00:00+00:00
    4    1970-01-01 00:00:00+00:00
    5    1970-01-01 00:00:00+00:00
    ...
    

However, if I convert any sublist of 60 elements or fewer, I can get back a
correct series:

    
    
    from datetime import datetime
    from datetime import timedelta
    from dateutil import parser
    
    day = parser.parse('2016-08-07T00:00:00Z')
    dates = [day + timedelta(days=delta) for delta in range(80)]
    
    pandas.Series(dates[0:60])
    

Note the last line, the input of pandas.Series becomes dates[0:60]. In fact,
it can be any dates[n:n+60], where n is between 0 and len(dates) - 60.

    
    
    0    2016-08-07 00:00:00+00:00
    1    2016-08-08 00:00:00+00:00 
    2    2016-08-09 00:00:00+00:00
    3    2016-08-10 00:00:00+00:00
    4    2016-08-11 00:00:00+00:00
    5    2016-08-12 00:00:00+00:00
    ...
    

I also read the Pandas document on Series and datetime, and tried Pandas'
timestamp, but still go the the same result. The Pandas version is 0.18.1, and
the Python version used by the iPython notebook kernel is 2.7.3:

    
    
    print  pandas.__version__
    
    import sys
    print(sys.version)
    

The output is

    
    
    0.18.1
    2.7.3 (default, Jun 22 2015, 19:33:41) 
    [GCC 4.6.3]
    

Any hints on what I should look into to find out why this problem happens and
how to fix it?

Thanks,


Answer: I don't know what's wrong with your Python version, but you can and should use
vectorized (i.e. much more efficient and faster) pandas methods instead of
vanilla Python methods:

    
    
    In [181]: pd.Series([pd.to_datetime('2016-08-07T00:00:00Z') + pd.Timedelta(days=delta) for delta in range(80)])
    Out[181]:
    0    2016-08-07
    1    2016-08-08
    2    2016-08-09
    3    2016-08-10
    4    2016-08-11
    5    2016-08-12
    6    2016-08-13
    7    2016-08-14
    8    2016-08-15
    9    2016-08-16
    10   2016-08-17
    11   2016-08-18
    12   2016-08-19
    13   2016-08-20
    14   2016-08-21
    15   2016-08-22
    16   2016-08-23
    17   2016-08-24
    18   2016-08-25
    19   2016-08-26
    20   2016-08-27
    21   2016-08-28
    22   2016-08-29
    23   2016-08-30
    24   2016-08-31
    25   2016-09-01
    26   2016-09-02
    27   2016-09-03
    28   2016-09-04
    29   2016-09-05
            ...
    

