【发布时间】:2018-04-24 15:18:42
【问题描述】:
行等于下面。 PIC_loc = 23;我想要 42 和 42 之后的 15 位。输出应该是 42011721930018984
PIC_1 p_lgth Wgt
**PARTIAL-DECODE***P / 42011721930018984390078... 53 112
Output = row['PIC_1'][PIC_loc:PIC_loc+15]
上面的代码给出了这个错误信息
TypeError: cannot do slice indexing on
class 'pandas.core.indexes.range.RangeIndex'> with these indexers [2 23
Name: PIC_1, dtype: int64] of <class 'pandas.core.series.Series'>
【问题讨论】:
-
PIC_1 是一个字符串;它是以“**PARTIAL”开头并以“0078...”结尾的整行
-
当你昨天问这个问题时,Joran Beasley 在评论中给了你一个尝试的解决方案,即
fifteencharactersfollowing42 = a_string.split("42",1)[-1][:15]。那没有用吗?如果PIC_1是您描述的字符串,它对我来说很好。 -
给出消息“KeyError:-1”