Guys I have a Dataframe
df= pd.DataFrame({'Point_ID':[1,2,3,1,2,1] , 'Shape_ID': [84,85,86,87,88,89],'LOL':[0,1,0,1,np.nan,np.nan]})
Out[1116]:
LOL Point_ID Shape_ID
0 0.0 1 84
1 1.0 2 85
2 0.0 3 86
3 1.0 1 87
4 NaN 2 88
5 NaN 1 89
When I did :
df.groupby('Point_ID').last()
Out[1114]:
LOL Shape_ID
Point_ID
1 1.0 89
2 1.0 88
3 0.0 86
On Shape_ID it returned the last value , but on LOL should it return NaN ?
By using max, I get the same answer as I using last() when the Dataframe is sorted
df.groupby('Point_ID').max()
Out[1115]:
LOL Shape_ID
Point_ID
1 1.0 89
2 1.0 88
3 0.0 86
I am reading the pandas file about the both function first and last, can not find the answer.
Is there anyone can help ? Much appreciate~~:-)