I have a dataframe and I would like to round up the Loss Ratio column to 2 decimal places. Here is my dataframe:
Month Death benefit premium revenue Loss Ratio Total Claims
0 July-2020 50 0.900 45.00
1 August-2020 40 0.800 32.00
2 September-2020 40 0.900 36.00
3 October-2020 50 0.690 34.50
4 November-2020 40 0.900 36.00
5 December-2020 50 0.805 40.25
6 January-2021 40 0.794 31.76
7 February-2021 40 0.783 31.32
8 March-2021 50 0.772 38.60
9 April-2021 40 0.800 32.00
10 May-2021 60 0.700 42.00
11 June-2021 50 0.950 47.50
I would like my Loss Ratio column to become like this:
Month Death benefit premium revenue Loss Ratio Total Claims
0 July-2020 50 0.90 45.00
1 August-2020 40 0.80 32.00
2 September-2020 40 0.90 36.00
3 October-2020 50 0.70 34.50
4 November-2020 40 0.90 36.00
5 December-2020 50 0.81 40.25
6 January-2021 40 0.79 31.76
7 February-2021 40 0.78 31.32
8 March-2021 50 0.77 38.60
9 April-2021 40 0.80 32.00
10 May-2021 60 0.70 42.00
11 June-2021 50 0.95 47.50
I have tried two ways to round the Loss Ratio column to 2 decimal places using the following codes:
df['Loss Ratio'] = df['Loss Ratio'].round(2)
df['Loss Ratio'] = round(df['Loss Ratio'], 2)
My output after the running the codes is:
Month Death benefit premium revenue Loss Ratio Total Claims
0 July-2020 50 0.90 45.00
1 August-2020 40 0.80 32.00
2 September-2020 40 0.90 36.00
3 October-2020 50 0.69 34.50
4 November-2020 40 0.90 36.00
5 December-2020 50 0.80 40.25
6 January-2021 40 0.79 31.76
7 February-2021 40 0.78 31.32
8 March-2021 50 0.77 38.60
9 April-2021 40 0.80 32.00
10 May-2021 60 0.70 42.00
11 June-2021 50 0.95 47.50
I noticed that the fifth value in Loss Ratio column, 0.805 did not round to 0.81 but it rounded to 0.80 instead. Can anyone please advice me how to fix this problem please? Thank you so much for your help!