12345678_0001
import pandas as pd
df = pd.read_csv('xxx.csv', header=0, encoding='utf-8')
age_interval = [(lower, upper) for lower, upper in zip(range(0, 96, 5), range(5, 101, 5))]def age_partition(age):
""" 将年龄分类 """
for lower, upper in age_interval: if age is None: return "None"
elif lower <= age <= upper: return f"({lower}, {upper})"df['new_col'] = df.age.apply(age_partition)