0
我有一組和一個函數來刪除在我的熊貓數據幀的可變'nstandar'
琴絃。該組中,功能和熊貓數據幀如下:錯誤上從大熊貓數據幀中移除串 - 的Python
setc={'adr','company','corporation','energy','etf','group','holdings','inc','international','ltd'}
def quitarc(x):
x=''.join(a for a in x if a not in setc)
return x
Company name nstandar
0 1-800-FLOWERS.COM 1800flowerscom
1 1347 PROPERTY INS HLDGS INC 1347 property ins hldgs inc
2 1ST CAPITAL BANK 1st capital bank
3 1ST CENTURY BANCSHARES INC 1st century bancshares inc
4 1ST CONSTITUTION BANCORP 1st constitution bancorp
5 1ST ENTERPRISE BANK 1st enterprise bank
6 1ST PACIFIC BANCORP 1st pacific bancorp
7 1ST SOURCE CORP 1st source corporation
8 1ST UNITED BANCORP INC 1st united bancorp inc
9 21ST CENTURY ONCOLOGY HLDGS 21st century oncology hldgs
然而,當我創建一個新的變量,而不串移除,新的變量只是一樣'nstandar'
。代碼如下:
cemp['newnstandar']=cemp['nstandar'].apply(quitarc)
那麼,什麼是我的錯誤?我如何修復我的代碼?