This is my first post on StackOverflow. My apologies if I do something wrong or against the web's rules.
My problem: I have a csv file I read using pandas
in python. The dataframe has five columns, named [yday, wday, time, stop, N]
:
yday
is the year's day, from 1 to 365;
wday
is the week's day, from 1 to 7;
time
is a number from 1-144 (I divide the day in gaps of 10 minutes each, 1440 minutes per day/10 minutes = 144);
stop
is a the number of the bus stop (1-4);
N
is the number of ppl who enter the bus
Well, I would like to have an entry for each gap, giving 144 rows per day, but I have some missing gaps as you can see: CSV example
My goal is to add new rows to fill all the time gaps, like adding (based on the image given):
320,6,81,1,1 <-- Exists
320,6,82,1,na <-- New
320,6,83,1,na <-- New
320,6,84,1,na <-- New
320,6,85,1,1 <-- Exists
I tried to index my DataFrame
with df.set_index['stop','yday','time']
so I could reindex it with 'time'
values from 1
to 144
, but it doesn't work. I'm new to Python and i'm getting mad trying to solve this.
Thanks in advance and sorry for my english.