Using A Regular Expression To Show Rows In Pandas (Python)
-
Hi there, Here is part of a Python Code I have :-
#convert df['Durn'] column to datetime foramt
df['Durn']= pd.to_datetime(df['Durn'],format='%H:%M:%S').apply(pd.Timestamp)
#print("changing datatype of column Durn----->",df['Durn'].dtype)
#print("=======")
#compare minutes with extracting minutes from datetime64 column
comparelist=[5,10,15,20,]
df['Dakota And Fighters In The Same Display Slot'] = ((df['DISPLAY/'] == 'DISPLAY') & (df['Durn'].dt.minute.isin(comparelist))).map({True:'YES', False:'NO'})
#print(df)
#print("applied... the condition to compare minutes for Durn column")
#print("=======")The Rows that, I would like showing, and that have in the 'Dakota And Fighters In The Same Display Slot' Column, saying 'NO', arn't showing in the output. For a given Venue, in the 'Venue' Column, the rows not showing, both Minute Values in the 'Durn' Column, differ i.e. are normally 5 and 10. Only the Rows with matching values, in the 'Durn' Column i.e. 5 and 5, 10 and 10, 15 and 15, 20 and 20. etc are displaying in the Output I get. Those are the ones that say 'Yes', in the Column I have mentioned already.
What Regular Expression with using Maths, could I add to my Code, so that those Rows, I want showing show ?
Any help would be appreciated
Regards
Eddie Winch :)