Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem in Regex Expression
#1
I have file where I want to replace the particular row when a particular thing(string) matches with semicolon. If Equipment onsite is null/nothing then replace with semicolon, otherwise if there is anything after equipment onsite, I wanted to keep as it is. Check the image how the output look likes. any help what wrong in regular expression.

import pandas as pd 
import re

data = pd.read_csv("TestEquipmentOnsite.csv", header=0) 

data = data.replace(r",Equipment onsite=", ";", regex=True) 
print(data)

Attached Files

Thumbnail(s)
   

.csv   TestEquipmentOnsite.csv (Size: 204 bytes / Downloads: 199)
Reply
#2
Is there something wrong? Your output seems to match your description.
Reply
#3
(Sep-28-2021, 03:36 AM)bowlofred Wrote: Is there something wrong? Your output seems to match your description.

I attach image how I wanted the output to look like. If you run the code, the output look like quite different what I wanted.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in matching in regex akbarza 1 411 Nov-21-2023, 09:31 AM
Last Post: snippsat
  [solved] Regex expression do not want to taken :/ SpongeB0B 2 781 Nov-06-2023, 02:43 PM
Last Post: SpongeB0B
  Regex Include and Exclude patterns in Same Expression starzar 2 807 May-23-2023, 09:12 AM
Last Post: Gribouillis
  Regex Expression With Code Query In Pandas eddywinch82 8 2,369 Apr-13-2022, 09:12 AM
Last Post: snippsat
  plotly expression problem Visiting 2 2,014 May-16-2021, 12:28 AM
Last Post: Visiting
  Using Regex Expression With Isin in Python eddywinch82 0 2,299 Apr-04-2021, 06:25 PM
Last Post: eddywinch82
  2 regex expression at a time tokstolle 2 2,096 May-27-2020, 05:00 PM
Last Post: bowlofred
  Pass results of expression to another expression cmdr_eggplant 2 2,302 Mar-26-2020, 06:59 AM
Last Post: ndc85430
  How to assign a found regex expression to a variable Pedroski55 2 3,049 Nov-24-2018, 07:14 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020