我在数据框中有一列,我想通过将cpro列中的每个值加到小于10的前面加上“ 0”,将其转换为两位数。我用以下方式将其转换为“ 0” '.join(df.loc [df ['cpro'] <10,'cpro']。astype(str).tolist())
其中x
是要填充的字符串:
x.zfill(2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.