# I'm trying to do a time series model without a datetime field in python. Is this possible?

I have a dataset with data like this:

Day       Revenue
1          1.2
2          1.5
3          1.1
4          1.34


I want to do a time series model on it, but am getting this error:

ValueError: view limit minimum -35.45 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units

When I plt, it assigns all of the date to 1/1/1970. I understand why, because it's not a date time field. Out of curiosity, I tried converting the Day column to a datetime, but it assigned every day to 1/1/70. Is there a way to either convert the column to a datetime field and have it assign a new date starting with a specific date (say 1/1/2017, 1/2/2017, etc) or is there a work around when you just have the day counts (1,2,3,4)?

You can use timedelta function from datetime to achieve this, starting from a known date.

Example code can be something like,

from datetime import datetime, timedelta

start = datetime.strptime('2021-01-01', '%Y-%m-%d')

all_dates = [start + timedelta(x) for x in range(10)]

print(all_dates)


Replace the range(10) above with the sequence of the actual days in your dataset.