The regular python int function only works for scalars. You should either use a numpy function to round the data, either

Copys = np.round((s - s % bucket_size) / bucket_size) #to round properly; or
s = np.fix((s - s % bucket_size) / bucket_size)   #to round towards 0

and if you actually want to convert to an integer type, use

Copys = s.astype(int)

to cast your array.

Answer from Andras Deak -- Слава Україні on Stack Overflow
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to convert python pandas series to integer
5 Best Ways to Convert Python Pandas Series to Integer - Be on the Right Side of Change
February 19, 2024 - Here, to_numeric() is combined with errors='coerce' to convert non-numeric values to NaN, which are then filled with 0 using fillna(0) before converting the Series to integers. This method elegantly handles errors and provides flexibility in ...
Discussions

python - Simple way to convert a Pandas Series for integer comparison - Stack Overflow
To subscribe to this RSS feed, copy and paste this URL into your RSS reader. More on stackoverflow.com
🌐 stackoverflow.com
python - Convert float Series into an integer Series in pandas - Stack Overflow
In [37]: ts = rise_p['time']/100 ... only length-1 arrays can be converted to Python scalars · How do I convert ts into an Integer Series since int() doesn't take a Series or a list as an argument? Is there any method in pandas which does this?... More on stackoverflow.com
🌐 stackoverflow.com
September 26, 2013
python - How to convert from pandas Series to an int - Stack Overflow
I'm trying to convert times from UTC to local times for various countries. To do this I'm searching a dataframe for the country name to find the timezone if (country == "Brazil" or countr... More on stackoverflow.com
🌐 stackoverflow.com
python - Convert all elements in float Series to integer - Stack Overflow
I want to convert all the values to integer or just round it up so that there are no decimals. Let us say the dataframe is df and the column is a, I tried this : ... I got an error saying this method can't be applied to a Series, only applicable to individual values. ... After this I printed df but there was no change. Where am I going wrong? ... round won't work as it's being called on a pandas ... More on stackoverflow.com
🌐 stackoverflow.com
March 13, 2016
🌐
Microsoft Community
community.fabric.microsoft.com › t5 › Power-Query › How-to-convert-pandas-core-series-Series-to-type-int-when-I-use › td-p › 2223411
How to convert 'pandas.core.series.Series' to type 'int' when I use a python script within powerquer
December 9, 2021 - 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...).
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.convert_dtypes.html
pandas.Series.convert_dtypes — pandas 3.0.3 documentation
If the dtype is numeric, and consists of all integers, convert to an appropriate integer extension type. Otherwise, convert to an appropriate floating extension type. In the future, as new dtypes are added that support pd.NA, the results of this method will change to support those new dtypes. ... >>> df = pd.DataFrame( ... { ... "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")), ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_numeric.html
pandas.to_numeric — pandas 3.0.3 documentation - PyData |
If not specified, the default behavior is to not use nullable data types. If specified, the behavior is as follows: "numpy_nullable": returns nullable-dtype-backed object · "pyarrow": returns with pyarrow-backed nullable object · Added in version 2.0. ... Numeric if parsing succeeded. Return type depends on input. Series if Series, otherwise ndarray.
🌐
Saturn Cloud
saturncloud.io › blog › pandas-convert-string-to-int-a-guide-for-data-scientists
Pandas Convert String to Int A Guide for Data Scientists | Saturn Cloud Blog
June 19, 2023 - To convert a string to an integer using Pandas, you can use the astype() method. This method is available on Pandas Series and DataFrame objects and can be used to convert the data type of a column from one type to another.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › convert-a-dataframe-column-to-integer-in-pandas
Convert a Dataframe Column to Integer in Pandas - GeeksforGeeks
March 2, 2026 - This method is best when the data is clean, and you are sure that all values in the column can be successfully converted to integers without any errors. ... import pandas as pd # Creating a sample DataFrame data = {'Column1': ['1', '2', '3', '4']} df = pd.DataFrame(data) df['Column1'] = df['Column1'].astype(int) print(df) print(df['Column1'].dtype)
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas convert column to int in dataframe
Pandas Convert Column to Int in DataFrame - Spark By {Examples}
June 26, 2025 - How to convert the Pandas column to int in DataFrame? You can use DataFrame.astype(int) or DataFrame.apply() method to convert a column to int
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to convert python series from bool to int
5 Best Ways to Convert Python Series from Bool to Int - Be on the Right Side of Change
February 24, 2024 - Another way to perform the conversion is to use the apply function in combination with Python’s int type constructor. This method gives you the flexibility of applying any custom function to the series elements. ... import pandas as pd # Create a boolean series bool_series = pd.Series([True, False, True]) # Convert to integer series int_series = bool_series.apply(int) print(int_series)
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.astype.html
pandas.Series.astype — pandas 3.0.3 documentation - PyData |
>>> ser = pd.Series([1, 2], dtype="int32") >>> ser 0 1 1 2 dtype: int32 >>> ser.astype("int64") 0 1 1 2 dtype: int64 · Convert to categorical type: >>> ser.astype("category") 0 1 1 2 dtype: category Categories (2, int32): [1, 2] Convert to ordered categorical type with custom ordering: >>> from pandas.api.types import CategoricalDtype >>> cat_dtype = CategoricalDtype(categories=[2, 1], ordered=True) >>> ser.astype(cat_dtype) 0 1 1 2 dtype: category Categories (2, int64): [2 < 1] Create a series of dates: >>> ser_date = pd.Series(pd.date_range("20200101", periods=3)) >>> ser_date 0 2020-01-01 1 2020-01-02 2 2020-01-03 dtype: datetime64[us] On this page
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-string-to-integer-in-pandas-dataframe
How to Convert String to Integer in Pandas DataFrame? - GeeksforGeeks
July 15, 2025 - Syntax: Series.astype(dtype, copy=True, errors=’raise’) Parameters: This method will take following parameters: dtype: Data type to convert the series into.
🌐
Statology
statology.org › home › pandas: how to convert object to int
Pandas: How to Convert object to int
July 16, 2022 - This tutorial explains how to convert a column in a pandas DataFrame from an object to an integer, including examples.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas convert string to integer
Pandas Convert String to Integer - Spark By {Examples}
June 3, 2025 - To convert a string column to an integer in a Pandas DataFrame, you can use the astype() method. To convert String to Int (Integer) from Pandas DataFrame
🌐
LinkedIn
linkedin.com › pulse › change-data-type-columns-pandas-mohit-sharma
Change the data type of columns in Pandas
February 8, 2021 - >>> s = pd.Series([1, 2, -7]) >>> s 0 1 1 2 2 -7 dtype: int64 · Downcasting to 'integer' uses the smallest possible integer that can hold the values: