最佳答案
您可以使用rsplit
限制为 1 并选择第二个值 list
s:
df = df.applymap(lambda x: x.rsplit(':', 1)[1])
或者:
df = df.apply(lambda x: x.str.rsplit(':', 1).str[1])
print (df)
dsn cnt retry rssir lqir rssif lqif
0 113 1 1 -24 6 -49 5
1 114 2 1 -24 10 -49 15
2 115 3 1 -24 5 -59 14
3 116 4 1 -24 8 -58 11
4 117 5 1 -24 12 -57 14
或者更简单地指出Anton vBR :
df = df.applymap(lambda x: x.rsplit(':')[-1])
df = df.apply(lambda x: x.str.rsplit(':').str[-1])
关于python - 如何用 pandas reshape 数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50480760/