Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
brightcitrus
Frequent Visitor

Run Python script for parsing text including RegEx formulas?

Hello community,

I am parsing a free text field from a .xslx file (retrieved from database) using Python regular expressions. Indeed, I need to filter the free text and retrieve very specific data which can only be done using regular expressions, and then store the parsed data in new columns of the file. A sample of the code: 

line_pattern = r'(?i)(line item\.*\s*\d+|line\.*\s*\d+|lines\.*\s*\d+|line items\.*\s*\d+)'
df['LINE'] = df['FMEA Assessment'].str.findall(line_pattern)

My company is using Power BI mostly for reporting purposes and implementing my script within the desktop to automatically parse the data would be great.

I have tried Get Data -> Load -> Edit Queries -> Run Python script, but I get the following error message.

Capture.PNG

 

 

 

 

Any help using Python scripts including regular expressions, or using only regular expressions to parse text and populate new columns would be greatly appreciated.

Thank you!

 

 

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@brightcitrus ,

 

The error message mentioned that you haven't installed the site-package "pandas", please install pandas library using pip. For more details, you can refer to steps in blog below:
https://data-flair.training/blogs/install-pandas-on-windows/

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@brightcitrus ,

 

The error message mentioned that you haven't installed the site-package "pandas", please install pandas library using pip. For more details, you can refer to steps in blog below:
https://data-flair.training/blogs/install-pandas-on-windows/

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Good Morning,

 

Thank you for your reply @. I double checked pandas and they are indeed installed so I am not sure what the problem might be. I installed them again just to be safe but I still get an error message.

 

Attached is the latest error message I get. Not sure what is ADO.NET?

 

Thank you again for your help.

Capture.PNG

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.