I need to select rows with greater than a count number (ie 1) of items in the mac column. Then create a DataFrame with the minimum and maximum value of timestamp.
a=np.array([['A',1],['A',2],['A',3],['B',2],['C',1],['C',2]])
df=pd.DataFrame(a,columns=['mac','timestamp'])
df
Out[103]:
mac timestamp
0 A 1
1 A 2
2 A 3
3 B 2
4 C 1
5 C 2
count_macs= df.groupby(['mac'])['mac'].count()>1
count_macs
Out[105]:
mac
A True
B False
C True
Name: mac, dtype: bool
I would like to get:
mac ts1 ts2
A 1 3
C 1 2
But don't know how to apply correctly .loc :
df.loc[count_macs]
IndexingError: Unalignable boolean Series key provided