# convert series to dataframe, elevate index to column
df = s.to_frame('Value').reset_index()
# split by dash and exclude final split
df[['x', 'y']] = df['index'].str.split('-', expand=True).iloc[:, :-1].astype(int)
print(df)
index Value x y
0 4-5-a 2 4 5
1 6-7-d 3 6 7
2 9-6-c 7 9 6
3 5-3-k 8 5 3
这是一种方法。你知道吗
相关问题 更多 >
编程相关推荐