根据多个列更改列值

时间:2019-08-19 15:38:59

标签: python-3.x pandas

我正在开发用于在给定数据中搜索关键字的代码。     例如,我在A列中有一个数据,我想确定是否     如果是,则该子字符串出现在行中     数据,如果该关键字不存在,请给我“空白”。

import pandas as pd
data = pd.read_excel("C:/Users/606736.CTS/Desktop/Keyword.xlsx")

# dropping null value columns to avoid errors 
data.dropna(inplace = True)
# Converting the column to uppercase
data["Uppercase"]= data["Skill"].str.upper()

# Below is the keywords I want to search in the data
sub =['MEMORY','PASSWORD','DISK','LOGIN','RESET']
# I have used the below code, which is creating multiple columns & 
giving me the boolean output
for keyword in sub:
data[keyword] = data.astype(str).sum(axis=1).str.contains(keyword)
 # what I want is, search the keyword if it exits give me the keyword 
  name else blank

1 个答案:

答案 0 :(得分:0)

尝试一下:

builder = tfds.builder("tfds.image.food101.Food101")
builder.download_and_prepare()
datasets = builder.as_dataset()