Python 如何使用iloc获取索引列表?

Python 如何使用iloc获取索引列表?,python,pandas,vectorization,Python,Pandas,Vectorization,我已经按照我想要的方式对数据进行了排序。 我将加入一些类似的内容: series_data = [] for count,x in enumerate(df): series_data.append(list(range(count))) df['up_to_row'].iloc(count)= series_data 因此,专栏将是: df['up_to_row'] = Series([0], [0,1], [0,1,2], [0,1,2,3]...) 然后我需要将这个iloc

我已经按照我想要的方式对数据进行了排序。 我将加入一些类似的内容:

series_data = []
for count,x in enumerate(df):
   series_data.append(list(range(count)))
   df['up_to_row'].iloc(count)= series_data
因此,专栏将是:

df['up_to_row'] = Series([0], [0,1], [0,1,2], [0,1,2,3]...)
然后我需要将这个iloc位置转换为索引

有没有更具体的方法? 我会用pandas操作符来实现这一点,但我不确定如何获得当前的iloc,这就是为什么需要枚举

编辑* 使用@wen的一些工具找到了最终答案。多谢各位

data['ind']=data.index.astype(str)+','
data['cumsum_indexes']=data['ind'].cumsum().str[:-1].str.split(',')
使用cumsum,注意它会将列表中的数字转换为str,而不再是int

df['up_to_row']=np.arange(len(df))
(df['up_to_row'].astype(str)+',').cumsum().str[:-1].str.split(',')
Out[211]: 
0             [0]
1          [0, 1]
2       [0, 1, 2]
3    [0, 1, 2, 3]
Name: up_to_row, dtype: object

你能从series_data.appenddf.index[listrangecount]开始吗?我喜欢str+','。如何将这些iloc转换为它们表示的索引?