【发布时间】:2019-03-06 16:52:56
【问题描述】:
我有一个看起来像这样的熊猫数据框 df:
a b
thisisastring 5
anotherstring 6
thirdstring 7
我想根据 b 列中的数字从 a 列中的字符串左侧删除字符。所以我尝试了:
df["a"] = d["a"].str[df["b"]:]
但这会导致:
a b
NaN 5
NaN 6
NaN 7
代替:
a b
sastring 5
rstring 6
ring 7
有什么帮助吗?提前致谢!
【问题讨论】:
标签: string python-3.x pandas