Question
I am trying to come up with a way to assign values to dates in my panda's data frame. I currently have a list of
I am trying to come up with a way to assign values to dates in my panda's data frame. I currently have a list of dates grouped by "state" as shown in the screenshot. I would like to have "03-01-2020" be "day 1" and the current day be the last day-- in a column called "day". I tried using this code to create the dictionary I could use in the Pandas dataframe with the code below.
counter = 0
dict1 = {}
for i in df.date:
if i not in dict1:
counter +=1
dict1[i] = counter
Now I would like to create a column where the day corresponds to the date. How would I do that?
date state Deaths Cases 1 2020-03-01 AK 0 15.5000 2 2020-03-02 AK 0 28.4048 3 2020-03-03 AK 0 43.8333 4 2020-03-04 AK 0 60.8905 5 2020-03-05 AK 0 81.3548Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started