0

I have a DataFrame, you can have it by running:

import pandas as pd
from io import StringIO

df = """  

               case_id    scheduled_date        status_code
               1213       2021-08               1
               3444       2021-06               0
               4566       2021-07               2
               12213      2021-08               2
               34344      2021-06               0
               44566      2021-07               2
               1213       2021-08               0
              
        """
df= pd.read_csv(StringIO(df.strip()), sep='\s\s+', engine='python')

This outputs:

  case_id   scheduled_date  status_code
0   1213    2021-08         1
1   3444    2021-06         0
2   4566    2021-07         2
3   12213   2021-08         2
4   34344   2021-06         0
5   44566   2021-07         2
6   1213    2021-08         0

How can I replace the status_code value with {1:'success',0:'fail',2:'unknown'},the output should be:

  case_id   scheduled_date  status_code
0   1213    2021-08         success
1   3444    2021-06         fail
2   4566    2021-07         unknown
3   12213   2021-08         unknown
4   34344   2021-06         fail
5   44566   2021-07         unknown
6   1213    2021-08         fail
William
  • 3,724
  • 9
  • 43
  • 76

0 Answers0