Replace data from a data frame

Hello to the whole community:
I have a question, and I want to ask for help, please.
I have a data frame, with data between 0 and 1 (see the image). The data can be for example 0 or also 0.45, etc.

I need to rewrite that table, but by categories or sections, that is, for example, all the numbers that are between 0 and 0.2, replace them with 0.1. If the numbers are between 0.5 and 0.78556, it should be replaced by 0.6 (this is just an example).

How could I do it? I was thinking of something like:

for i in dataframe1[0:23]:

for j in dataframe1.index:

if 0<dataframe1.getloc[j,i]<10:

  dataframe2=dataframe1.replace(dataframe1.loc[j,i],8)

dataframe2

But I have not had good results.

I would appreciate any help, please.

I have some questions that you should consider answering to help me get your requirement known well:

  • What is the logic behind rounding off the numbers?
  • Do you mean to just rewrite the rounded number at the same place or do something else with the section thing?
  • Can you just show an example of expected dataframe?

If you just want to replace the rounded number at the same place, you can directly process on the dataframe.

For example if you want to round the numbers in a 0.2 difference range like-
Input:
....A....B
0 0.224 0.123
1 0.323 0.555
2 0.923 0.099

Output:
...A....B
0 0.2 0.0
1 0.2 0.4
2 0.8 0.0

You can do it directly like - df = (df//0.2)*0.2.