相关文章推荐
礼貌的机器人  ·  javax.net.ssl.SSLExcep ...·  3 天前    · 
犯傻的铅笔  ·  Spring WebClient使用 - ...·  3 天前    · 
睿智的松鼠  ·  HTTP客户端之Spring ...·  3 天前    · 
打盹的板栗  ·  前端传递JSON数组数据到后端(解析方法)_ ...·  昨天    · 
冷冷的草稿本  ·  txt文件转数组_python读取txt为数组·  3 小时前    · 
欢快的拐杖  ·  jquery实现tr元素的上下移动示例代码_ ...·  1 年前    · 
直爽的海豚  ·  conda ...·  2 年前    · 
飘逸的手链  ·  Python+OpenCV与海康工业相机交互 ...·  2 年前    · 
Code  ›  RangeIndex对象不可调用开发者社区
string
https://cloud.tencent.com/developer/ask/sof/1304677
酷酷的牙膏
1 年前
首页
学习
活动
专区
工具
TVP 最新优惠活动
返回腾讯云官网
提问
问 RangeIndex对象不可调用
Stack Overflow用户
提问于 2019-03-31 16:18:31
EN

我正在从文本文件中读取值,并尝试查找如下所示的子字符串的索引

df=pd.read_csv('break_sent.txt', index_col=False,encoding='utf-8',delimiter="\n",names=['sent'])
#print(df[:50])
#df.index = list(df.index)
df1= df[40:50]
print(len(df))
print(df1.index)
print("-------------------------------------------")
for i,row in df1.iterrows():
    string = row['sent']
    #print("string",string)
    d = df1[df1.sent.str.match(string)] # if the result includes more than 1 value then we know that substring and its matching parent string are present, then I will eliminate the substring from the dataframe
    if len(d.index > 2):
        index_val = df.index(string)
        df.drop(df.index(string),inpace=True)
 
推荐文章
礼貌的机器人  ·  javax.net.ssl.SSLException: SSLEngine已关闭,SSLEngine已在webclient中关闭(Springboot)开发者社区
3 天前
犯傻的铅笔  ·  Spring WebClient使用 - 大坑水滴
3 天前
睿智的松鼠  ·  HTTP客户端之Spring WebClient - 钟小嘿
3 天前
打盹的板栗  ·  前端传递JSON数组数据到后端(解析方法)_element-china-area-data 前端json数组怎么转换成字符串传到后端
昨天
冷冷的草稿本  ·  txt文件转数组_python读取txt为数组
3 小时前
欢快的拐杖  ·  jquery实现tr元素的上下移动示例代码_jquery_脚本之家
1 年前
直爽的海豚  ·  conda 切换环境_生物信息学分析实用小技巧(四):R/Perl/Python环境的管理_weixin_39929602的博客-CSDN博客
2 年前
飘逸的手链  ·  Python+OpenCV与海康工业相机交互 - Python社区
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号