Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Pandas pd.date_range() HELP

Avi.Parker

New Coder
Python:
<start = dt.datetime(2022,1,1)
  end = dt.datetime(2023,1,1)
  dates = pd.date_range (start,end,freq='20D')
  print(dates)>
I am the definition of a newbie to python, not to mention the pandas extension, That being said is there any way that I can have the pd.date_range() line count from the end date backwards to the start date at the frequency given? Its for a Engineering class in University.
 
Python:
<start = dt.datetime(2022,1,1)
  end = dt.datetime(2023,1,1)
  dates = pd.date_range (start,end,freq='20D')
  print(dates)>
I am the definition of a newbie to python, not to mention the pandas extension, That being said is there any way that I can have the pd.date_range() line count from the end date backwards to the start date at the frequency given? Its for a Engineering class in University.
I personally don't use pandas, but you could reverse the list using slice notation, like so:
Code:
start = dt.datetime(2022,1,1)
end = dt.datetime(2023,1,1)
dates = pd.date_range (start,end,freq='20D')
print(dates)[::-1]
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom