Home > Back-end >  TypeError: 'generator' object is not callable when using pandas' date_range
TypeError: 'generator' object is not callable when using pandas' date_range

Time:11-23

I'm using pandas' date_range to generate datetime arrays:

time_array = pd.date_range(start='2020-6-1 00:00:00', end='2021-10-31 00:00:00', freq='H')

And when I start to debug my code, my IDE tells me this error:

past_predict_single.py::test_gen_line_model FAILED                       
past_predict_single.py:83 (test_gen_line_model)
def test_gen_line_model():
        back_hours = 72  
>       time_array = pd.date_range(start='2020-6-1 00:00:00', end='2021-10-31 00:00:00', freq='H')
E       TypeError: 'generator' object is not callable

But when I run my code, this error diappears.

And another interesting thing: after the error appeared on the 1st computer, I chose the 2nd computer to debug my code, but after running my code for several times, the 2nd computer also appeared this problem.

How to solve it?

CodePudding user response:

I cut my code to another python file and the problem disappeared.

  • Related