0

I'm trying to loop through column of numbers and replace a with the associated label from another text file using the index on the text file. But it keeps returning an error

#conditions.txt has the labels while 'Reason for absence' has the numbers

with open('conditions.txt') as f:
    lines = f.readlines()
ds = pd.DataFrame(lines)
index=ds.index
print(index)

newname=df['Reason for absence'].copy()

for value in newname:
    for i in index:
        if value in newname == index :
            newname=ds

1 Answers1

0

This issue seems to be related to another posted question. While the approaches are different, possibly you are looking for the same end result. Take a look at the provided solution here. If the solution is not helpful, request you provide the error message.