I have a data frame that looks like this:
df=pd.DataFrame({'Machine':['A','A','B','B','B'],
                 'Date':['1/1/2020','4/5/2020','4/1/2020','4/3/2020','5/1/2020'],
                'Production':[5,9,44,13,34],
                })
  Machine      Date  Production
0       A  1/1/2020           5
1       A  4/5/2020           9
2       B  4/10/2020         44
3       B  4/3/2020          13
4       B  5/1/2020          34
And I want it to be converted to this:
    A   B
0   5  13
1   9  44
2      34
Where the index is simply the rank of the dates in order.
Is there a way to do it without creating the rank column first?
raw_data["RANK"] = raw_data.groupby('Machine')["Date"].rank(method="first", ascending=True)
new_data = raw_data.pivot(columns = 'Machine', values = 'Production', index = 'RANK')
