Advertisement
elena1234

replace int column code with text value in Python

May 6th, 2022
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3.  
  4. da = pd.read_csv("nhanes_2015_2016.csv")
  5. da["DMDEDUC2x"] = da.DMDEDUC2.replace({1: "<9", 2: "9-11", 3: "HS/GED", 4: "Some college/AA", 5: "College",
  6.                                        7: "Refused", 9: "Don't know"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement