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
GoingDigital123
Regular Visitor

How to convert 'pandas.core.series.Series' to type 'int' when I use a python script within powerquer

I am using a python script to manipulate data within powerquery. When I pass a table from powerquery with the column data type as 'decimal number' in powerquery, it arrives at python as of class 'pandas.core.series.Series'. If I am not mistaken, all data that passes from powerquery to python actually gets there as 'pandas.core.series.Series', independently of their previous data type.

With that said, I want to convert this column type again to a number of any kind (float, integer...). I tried multiple ways of converting it but it never works and stays as pandas.core.series.Series. For example, I have tried doing:

dataset['start_t'] = pd.to_numeric(dataset['start_t']) # 'start_t' is my column name

raise Exception(type(dataset['start_t'])) # still gives type class 'pandas.core.series.Series'
                                          # I use raise exception because it print doesn't work in powerquery

This doesn't work as well

df['start_t'] = df['start_t'].astype(int)

If I am not able to get the column type as a number I don't think I will be able to manipulate data as I wish. I need to convert those values from Unix to a timestamp and do subtractions, but nothing of that works when I have a 'pandas.core.series.Series'.

I have also tried getting the column from powerquery as a 'text' type but I do still get a 'pandas.core.series.Series'.

How should I deal with this? Has anyone faced this issue?

1 REPLY 1
v-angzheng-msft
Community Support
Community Support

Hi, @GoingDigital123 

 

I can't reproduce your question due to lack of experience with pandas, how did you pass the table to python and get the type above?

 

Here is the thread I found, you can refer to it and check if this is useful to you.

 

Converting pandas.core.series.Series to dataframe with appropriate column values python

How can I turn a pandas.core.series.Series into a Dataframe? [duplicate]

How to convert pandas.core.series.Series object with Multiple index to a pandas Dataframe with all c...

how to assign a pandas.core.series.Series to a pandas dataframe column

How to covert pandas.core.series.Series to string?

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

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.