How do i concat part of a date with a file name after doing groupby.
I want to end up with an array:
'hello Jan 2 2014','hello Jan 2 2014'
The results of my code were a surprise.
import pandas as pd
from datetime import datetime
d = { 'File' : pd.Series(['hello', 'what']),
'Status' : pd.Series([0., 0.]),
'Error' : pd.Series([2., 2.]),
'AlertDays' : pd.Series([2., 2.]),
'Date' : pd.Series([datetime(2014, 1, 2), datetime(2014, 1, 2)])}
df=pd.DataFrame(d)
df['Date']=pd.to_datetime(df['Date'])
Faildf=df[df.Status==0]
Fx=Faildf.groupby('File')['Date'].max().reset_index()
Fx['concat']=Fx['File'] +' '+ str(Fx['Date'])
#FailArray=Fx['concat'].unique()
why is there more than one date... i thought i lost the others dates by doing the groupby and max? results:
>>> Fx
File Date concat
0 hello 2012-05-02 00:00:00 0 2012-05-02 00:00:00\n1 2012-05-02 00:00:...
1 what 2012-05-02 00:00:00 0 2012-05-02 00:00:00\n1 2012-05-02 00:00:...