I have a dataframe like:
dict_ = {'Col1':[0.54523, 0.24223, 0.94234],'Col2':[0.992324, 0.274336, 0.245435]}
df = pd.DataFrame(dict_, columns=dict_.keys())
| Col1 | Col2 |
|---|---|
| 0.54523 | 0.992324 |
| 0.24223 | 0.274336 |
| 0.94234 | 0.245435 |
And I want only to have the specific values 0.25, 0.5, 1.0, rounding the original df dataframe to the nearest possible number on the specific values.
So, I want df to become:
| Col1 | Col2 |
|---|---|
| 0.5 | 1.0 |
| 0.25 | 0.25 |
| 1.0 | 0.25 |
How to do this in python (preferably in a pandas dataframe)?