I tried to write a code for creating a bucket. since the column to be bucketed has a lot of decimal values and is a object datatype i converted the column into float type. After the type conversion and when running the bins the error occurs
What I have tried:
Here's my code
```
import pandas as pd
import numpy as np
df=pd.read_excel(r'D:\Practice Files\Anirudh Exercise Skin India.xlsx')
df['Basepacksize'] = df['Basepacksize'].astype(str).astype(float)
bins= ['0','10','15','30','50','100']
df1=pd.cut(df['Basepacksize'], bins=bins)
print(df1)
```
Here's the error that occurs
Traceback (most recent call last):
File "C:\Users\ani\PycharmProjects\pythonProject\main7.py", line 11, in <module>
df1=pd.cut(df['Basepacksize'], bins)
File "C:\Users\ani\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\reshape\tile.py", line 293, in cut
fac, bins = _bins_to_cuts(
File "C:\Users\ani\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\reshape\tile.py", line 444, in _bins_to_cuts
labels = _format_labels(
File "C:\Users\ani\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\reshape\tile.py", line 578, in _format_labels
precision = _infer_precision(precision, bins)
File "C:\Users\ani\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\reshape\tile.py", line 644, in _infer_precision
levels = [_round_frac(b, precision) for b in bins]
File "C:\Users\ani\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\reshape\tile.py", line 644, in <listcomp> levels = [_round_frac(b, precision) for b in bins]
File "C:\Users\ani\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\reshape\tile.py", line 628, in _round_frac
if not np.isfinite(x) or x == 0:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Process finished with exit code 1