Select by date to change value

+1 vote

df_subset looks like this:

          day        holiday       date    traffic_volume
0     Tuesday  New Years Day 2013-01-01              1439
1     Tuesday           None 2013-01-01              1502
2     Tuesday           None 2013-01-01               933
3     Tuesday           None 2013-01-01               576
4     Tuesday           None 2013-01-01               372
...       ...            ...        ...               ...
8568  Tuesday           None 2013-12-31              4504
8569  Tuesday           None 2013-12-31              3478
8570  Tuesday           None 2013-12-31              2711
8571  Tuesday           None 2013-12-31              2189
8572  Tuesday           None 2013-12-31              1457

[8573 rows x 8 columns]

I want to change the value in 'holiday' column to 'New Years Day' for those row which date is 2013-01-01, and run these codes BUT does not update:

from datetime import *
NYD=date(2013,1,1)
if df_subset.date is NYD:
    df_subset.replace('None','New Years Day')

Or are there better way to check date and update a cell in the dataframe?

Nov 9, 2019 in Python by Gkeace
• 130 points
727 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

How to update date automatically after a value change in django?

Hello @kartik, Only change your pub_date if published has ...READ MORE

answered Jul 3, 2020 in Python by Niroj
• 82,840 points
9,675 views
0 votes
1 answer

How to sort Counter by value using python?

Use the Counter.most_common() method, it'll sort the items for you: >>> ...READ MORE

answered May 23, 2018 in Python by charlie_brown
• 7,720 points
10,647 views
0 votes
1 answer

How to sort dictionary by value python

This would work: d = sorted(data, key = ...READ MORE

answered Nov 2, 2018 in Python by Nabarupa
721 views
+1 vote
3 answers

How to change/update cell value in Python Pandas dataframe?

You can use the at() method to ...READ MORE

answered Apr 8, 2019 in Python by Kunal
147,371 views
0 votes
1 answer

Not able to print cell value by index.

You have wrongly indexed. The index you ...READ MORE

answered Apr 8, 2019 in Python by Ganesh
612 views
0 votes
1 answer

How to change the default Django date template format?

Hello @kartik, Within your template, you can use ...READ MORE

answered Aug 7, 2020 in Python by Niroj
• 82,840 points
4,426 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP