程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Why use Pythons regularization re When findall extracts the desired feature data in Excel, it gets a null value?

編輯:Python
The phenomenon and background of the problem

I use pandas Read a EXCEL( by xlsx Format , The EXCEL It's from txt Imported ), And USES the re.findall Regularization wants to get the data , But you always get a null value [].

wdi=pd.read_excel(r"wdisp.xlsx",engine="openpyxl")
wyj_c=re.findall(r"1/\d+",str(wdi))
print(' result :',wyj_c)

Operation results and error reporting contents

result : []

My solution ideas and tried methods

I tried to EXCEL Manually enter... In '1/1000' as well as ' What I want 1/1000', You can get this after running '1/1000', It shows that the code can obtain character type or numeric data , But the values with the same characteristics in the original data can not be extracted .

What I want to achieve

It is hoped that the extracted features are ‘1/’ The data of




Take the answer :

df Not directly supported re, Suggest using

df.str.contains() This lookup contains characters df.str.findall() This value finds the corresponding character 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved