Python Forum
Loop over dataframe to fill in missing rows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop over dataframe to fill in missing rows
#3
Basically, I want to get the sums of the traffic count by site reference and vehicle class for each month. As part of the data cleaning I filter out site references that have less than 60 months of traffic activity, I then filter out site reference that have been duplicated (not many, only like 8 have this issues). I also filter out 2017-12 because the counts are weird so the data starts from Jan 2018. After all these filters the dataframe is probably still too big for a loop so keen to hear any ideas about how to go about this.

For site reference with no traffic, it should have 0. When there is no data for the day (i.e. row missing it is assumed the meter was down for that date.) I want to fill in the data for when the meter was down by taking the average of the last 7 days for that site reference by vehicle (heavy, light) and using that amount.

Does that clarify? I can share all my code if that is unclear.

Thanks
Reply


Messages In This Thread
RE: Loop over dataframe to fill in missing rows - by Scott - Jul-01-2024, 06:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find duplicates in a pandas dataframe list column on other rows Calab 2 2,163 Sep-18-2024, 07:38 PM
Last Post: Calab
  Pandas Dataframe Filtering based on rows mvdlm 0 2,079 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  change dataframe header with 2 rows tonycat 2 2,758 Oct-29-2020, 01:41 AM
Last Post: tonycat
  Interate for loop over certain columns in dataframe Finpyth 2 2,661 Mar-06-2020, 08:34 AM
Last Post: Finpyth
  newbie: loop, modify dataframe cells expat_th 5 6,472 Mar-03-2020, 09:05 PM
Last Post: jefsummers
  read_csv error and rows/columns missing karlito 9 7,631 Nov-11-2019, 06:48 AM
Last Post: karlito
  How to add a few empty rows into a pandas dataframe python_newbie09 2 18,474 Sep-20-2019, 08:52 AM
Last Post: python_newbie09
  Double 'for' loop and writing in a new columns dataframe marco_ita 0 2,280 Sep-07-2019, 12:44 PM
Last Post: marco_ita
  Dataframe Rows Sorting stranger14u 1 3,322 Dec-17-2018, 11:47 PM
Last Post: scidam
  Write specific rows from pandas dataframe to csv file pradeepkumarbe 3 7,106 Oct-18-2018, 09:33 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020