vendredi 5 juillet 2019

how do i search an excel document for a specific word and also build a new column with results from the search

So i'm new to python and im trying to search an excel worksheet using python for the "ICD" in each row and create a new column with the results so, if a row contained the word "ICD" Then in the new column the word "yes" would appear if it didn't then the word "no" would appear.

so far i've tried a lot of different ways but im stuck because im new to this. Here is what i have so far. it took me a while to even find a way to import the excel document itself, now i have to find a way to add the new column and search each row and put the result. i know that i need a loop and i know that i need an if/else statement but i dont know where to put them or wha to put in them. im using python 3.7

import pandas as pd
import xlrd
df = pd.read_excel (r'C:\New folder\CrohnsD.xlsx')
print (df)
import xlsxwriter
ICD=[
    str = df
    str.find("ICD",[ 0,[ 1057]])\
    if row contains "ICD"


]`

Aucun commentaire:

Enregistrer un commentaire