Inside of my tag_data.csv file I want to change the column for “Posts” value from “4532” to “1234” in the the row that contains “metal “
My csv file looks like this:
Tag Posts
0 plastic 2456
0 paper 3449
0 metal 4532
0 other 8722
The output should be the file updated and saved to look like this:
Tag Posts
0 plastic 2456
0 paper 3449
0 metal 1234
0 other 8722
This is what I’ve been trying:
read_csv = pd.read_csv(‘tag_data.csv’)
read_csv.loc[read_csv.Tag == ‘metal’, ‘Posts’], [‘Posts’] = 123.to_csv(‘tag_data.csv’)