I have a daframe with a series of period 1 month and frequency one second.
The problem the time step between records is not always 1 second.
time c1 c2
2013-01-01 00:00:01 5 3
2013-01-01 00:00:03 7 2
2013-01-01 00:00:04 1 5
2013-01-01 00:00:05 4 3
2013-01-01 00:00:06 5 6
2013-01-01 00:00:09 4 2
2013-01-01 00:00:10 7 8
Then I want to create an empty dataframe with the same columns and for the whole period corrected. That means with as many records as seconds has a month. This empty dataframe is fulfilled in principle with nan values:
time c1 c2
2013-01-01 00:00:01 nan nan
2013-01-01 00:00:02 nan nan
2013-01-01 00:00:03 nan nan
2013-01-01 00:00:04 nan nan
2013-01-01 00:00:05 nan nan
2013-01-01 00:00:06 nan nan
2013-01-01 00:00:07 nan nan
2013-01-01 00:00:08 nan nan
2013-01-01 00:00:09 nan nan
2013-01-01 00:00:10 nan nan
Then compare both, and fulfill the empty one, with the common rows with my first dataframe. The non-common should remain with nan values.
time c1 c2
2013-01-01 00:00:01 5 3
2013-01-01 00:00:02 nan nan
2013-01-01 00:00:03 7 2
2013-01-01 00:00:04 1 5
2013-01-01 00:00:05 4 3
2013-01-01 00:00:06 5 6
2013-01-01 00:00:07 nan nan
2013-01-01 00:00:08 nan nan
2013-01-01 00:00:09 4 2
2013-01-01 00:00:10 7 8
My try:
#Read from a file the first dataframe
df1=pd.read_table(fin,parse_dates=0],names=ch,index_col=0,header=0,decimal='.',skiprows=c)
#create an empty dataframe
N=86400 * 31#seconds per month
index=pd.date_range(df1.index[0], periods=N-1, freq='1s')
df2=pd.DataFrame(index=index, columns=df1.columns)
Now I try with merge or concat but without the expected result:
df2.merge(df1, how='outer')
pd.concat([df2,df1], axis=0, join='outer')