I have been trying to update all rows value of a specific column where another column's value matches with a specific value.I have followed this link:Modifying a subset of rows in a pandas dataframe
Using this just changes the very last row value,but all the other row values remain unchanged. Here is my code:
def update_status(self, isbn=0, status='yes'):
print("\nUpdating Status\n")
df = self.data
ndf = df[df['ISBN']==isbn]
if len(ndf) > 0:
print(df)
df.loc[df.ISBN==(isbn), 'STATUS'] = status
print(df)
print("\nUpdated\n")
self.data=df[['ID', 'AUTHOR', 'ISBN', 'TITLE', 'YEAR', 'STATUS']].copy()
os.remove(self.filname)
self.data.to_csv(self.filname, sep=',', encoding='utf-8')
else:
print("No Book Found\n")
Here is the output where ISBN=9332549532 and status='yes' output
instead of changing 2 rows ,only the last row is getting changed
It will be really helpful if i get the solution.
Thanks