我想在数据帧的索引上(而不是在列上)应用匿名函数(使用.apply()
),例如lambda x: x + 1
我做吗?
最佳答案
一种方法是:
df.set_index(df.index + 1)
另一个:
df.assign(index=lambda x: x.index+1).set_index('index')
关于python - 在 dataFrame 的索引上应用匿名函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47443716/