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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Python Query adding .0 to the end of a string

I am writing a power query to run a web scraper that goes through a list of ID's in my dataset and searches for them in a search bar on a site. For some reason, Power BI is adding ".0" to the end of every number.

 

So my code takes the ID from the dataset and converts it to a list. Then it converts the ID's to strings and strips the 00's at the beginning of the ID:

FRID_list = dataset["FRID__c"].tolist()
FRID_listn = [str(z) for z in FRID_list]
new_frid =[]
for q in FRID_listn:
     q.lstrip('0')
     new_frid.append(q.lstrip('0'))

 

Then it iterates through that list, and types it in to a search bar:

 

for ID in new_frid:
     browser.fill('query', 'FRID ' + ID + '\n')

 

When I run the code as a python visual, it works fine, but if I run it in the power query, it adds .0 to the end of the ID:

 

 Search Bar.PNG

 

It doesn't do that in the regular python visual though. I though initially that it was turning it in to a float, but the code specifically turns it in to a str to it can be stripped. Can someone please advise why this is doing this and what I can do to fix it?

3 REPLIES 3
horeca2
Regular Visitor

Have you found a solution? I have the same problem. I found that it occurs if there is at least one empty string or null value in the column. If the column does not contain empty strings or null then ".0" is not added to the number

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Sometimes Power Query will change data type automatically.

You could open Advanced editor to see if there is a Change type step.

Delete this step from the "Applied Steps" pane on the right.

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello @v-juanli-msft,

 

Thank you for the response.

 

There aren't any change steps that I can see, the advanced editor just has my code in it and the applied steps only has a filter step, then my python script. I have underlined in the picture below the step where it is typing the id into the search bar.

 

Code_LI.jpg

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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