Use numpy.arange
by length of DataFrame
:
df['C'] = np.arange(len(df))
Or yo ucan use DataFrame.shape
, thank you @Mehmet Burak Say?c?:
df['C'] = np.arange(df.shape[0])
print (df)
A B C
100 0 7 0
203 5 4 1
5992 0 10 2
2003 9 8 3
20 10 5 4
12 6 2 5
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…