I have a dataframe as below.
import pandas as pd
frame = pd.DataFrame({"a":range(7),'b':range(7,0,-1),
'id':['one','one','two','two','two','three','four'],
'date':['2019-05-01','2019-05-08','2019-05-01','2019-05-08','2019-05-15','2019-05-01','2019-05-15']})
print(frame)
pd.to_datetime(frame['date'],yearfirst=True)
It looks like:
0 7 one 2019-05-01
1 6 one 2019-05-08
2 5 two 2019-05-01
3 4 two 2019-05-08
4 3 two 2019-05-15
5 2 three 2019-05-01
6 1 four 2019-05-15
I expect each id has three rows of date.
The expected dataframe is:
0 7 one 2019-05-01
1 6 one 2019-05-08
1 6 one 2019-05-15
2 5 two 2019-05-01
3 4 two 2019-05-08
4 3 two 2019-05-15
5 2 three 2019-05-01
5 2 three 2019-05-08
5 2 three 2019-05-15
NA NA four 2019-05-01
NA NA four 2019-05-08
6 1 four 2019-05-15
How can I get this dataframe by using resample? Thank you!