如何在python中创建格式? [关闭]

下面是我要在python中为TENRCT变量创建的格式。

'0'=“ Q <'0'> =未知”,'1'-'3'=” N('1','2','3')=承租人'','4'=“ Q <' 4'> =所有者”;

df = pd.DataFrame({'age_group':[1,2,3,4,5,6,7,8,3,5,7,1],                    'TENRCT':['0','2','3','4','1','2','0','4','2','2','2',' 1']}) df

d = {1:'0-23',2:'24 -27',3:'28 -47',4:'48 -59',5:'60 -71',6:'72 -79' ,7:'80 -87',8:'88 -99'}

e = {0:'Q <'0'> =未知',1:'N('1','2','3')= Renter',2:'N('1','2', '3')= Renter',3:'N('1','2','3')= Renter',4:'Q <'4'> = Owner'}

打印匹配值

df.replace({“ TENRCT”:e})

谁能帮我这个。

评论