Would something like this work for you? The last example of 0.7 and 0.8 is a bit strange anyways. Why would you like them in the same group?
Reference to my_ciel
answer since nor python nor numpy has the builtin functionality to do a cieling round on arbitrary float positions: my_ciel answer
import numpy as np
import pandas as pd
# Some boilerplate to make your sample data reusable (I suggest u post your questions in such way
# that data can be easily coppied)
a = np.array([0.25,0.2,0.3,0.4,0.26,0.3,0.3,0.4,0.3,0.3,0.3,0.3,0.7,0.3,0.3,0.3,0.8,0.4,0.45,0.46,])
a = a.reshape(5,4)
df = pd.DataFrame(a)
df.columns = ["A","B","C","D"]
df["PartNo"] = ["A1","A2","A3","A4","A5"]
df = df[["PartNo","A","B","C","D"]]
# This does a cieling round at the desired float position
def my_ceil(a, precision=0):
return np.true_divide(np.ceil(a * 10**precision), 10**precision)
# Tolerance can be set here:
# 1 = 0.1 , 2 = 0.01 , 3 = 0.001 etc.
df["set"] = my_ceil(df["A"],1)
df["set"] = df["set"].astype('category').cat.codes
df