Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?

image text in transcribed

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.3548

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago