1

I have to develop production code to work with pandas 0.22.0. I get ValueError: Of the three parameters: start, end, and periods, exactly two must be specified when I run the following code

import pandas as pd
pd.date_range(start='2020-03-20 00:00', end='2020-03-21 00:00', periods=5)

why is this happening?

1
  • working fine for me!! Commented May 12, 2020 at 9:25

4 Answers 4

1

This might have something to do with the pandas version. When I checked it with python 3.6.8 (pandas==0.22.0), I also get the same error:

enter image description here

But it works fine with python 3.7.3 (pandas==0.24.2):

enter image description here

As per the documentation for pandas 0.22.0: Of the three parameters: start, end, and periods, exactly two must be specified. See the Notes section

Also checked it for the latest version of pandas. This is what it says: Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting DatetimeIndex will have periods linearly spaced elements between start and end (closed on both sides). See the Notes Section

Sign up to request clarification or add additional context in comments.

Comments

1

ValueError: Of the four parameters: start, end, periods, and freq, exactly three must be specified:

import pandas as pd

dates = pd.date_range('20180101', periods=6)

pd.date_range(start='2020-03-20 00:00', end='2020-03-21 00:00', periods=5)

Comments

0

A late answer but it may worth it You don't have to specify periods while you give start and end just give pd.date_range(start='2020-03-20 00:00', end='2020-03-21 00:00') or pd.date_range(start='2020-03-20 00:00', end='2020-03-21 00:00',freq='1Min')

Comments

0

As I test it and I think it's coming from the format of the date

You have to specify %d/%m/%Y %H:%M for parameter start and end and not %Y-%m-%d %H:%M

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.