第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

有沒有辦法在包含一萬個使用python編碼的實例的數據幀中找到特殊符號,如“?”,“*”,“NA”?

有沒有辦法在包含一萬個使用python編碼的實例的數據幀中找到特殊符號,如“?”,“*”,“NA”?

郎朗坤 2022-08-11 17:16:25
如何使用python代碼在數據框中查找特殊字符.并找到它們的位置。為此,我在python中使用正則表達式,但我沒有得到任何東西。如果每列包含特殊字符,則希望顯示該列的文本。
查看完整描述

1 回答

?
鳳凰求蠱

TA貢獻1825條經驗 獲得超4個贊

考慮到以下作為輸入數據幀,我已經執(zhí)行了操作。


    name    val

0   a   1

1   *   2

2   b   NaN

3   d   1

4   g   ?

5   t   3

6   h   4

import numpy as np

import pandas as pd


f=pd.read_csv('data_file.csv')

f=pd.DataFrame(f)


#the below loop will provide you with the location of null values. i.e. "NaN"

for i,j in zip(*np.where(pd.isnull(f))):

    print("{},{}".format(i,j))


o/p: 2,1


#similarly finding location of '*' and '?'

special=['*','?']

for k in special:

    print(np.where(f.applymap(lambda x: x == k)),'location for ',k)


o/p: 

(array([1], dtype=int64), array([0], dtype=int64)) location for  *

(array([4], dtype=int64), array([1], dtype=int64)) location for  ?



eg:

i/n: f.iloc[1,0]

o/p: '*'


查看完整回答
反對 回復 2022-08-11
  • 1 回答
  • 0 關注
  • 94 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號