Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. Using A Regular Expression To Show Rows In Pandas (Python)

Using A Regular Expression To Show Rows In Pandas (Python)

Scheduled Pinned Locked Moved Regular Expressions
pythonregexhelpquestion
1 Posts 1 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Eddie Winch
    wrote on last edited by
    #1

    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 :)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups