慕盖茨4494581
你可以这样做:df = df.assign(cut=pd.cut(x=df.a, bins = np.arange(0, len(data)+2, 100)))而a你可以这样做:df['c'] = df.groupby('cut')['a'].transform(lambda x: ','.join(map(str, x.values.tolist())))df.drop('cut', axis = 1) a b c0 1 1 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1...1 2 2 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1...2 3 3 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1...3 4 4 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1...4 5 5 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1...