I want to update values in pandas DataFrame
column "image file path"
. Funny thing is, whenever I print inside the IF
statement old and new value I see that update has occurred. But once I print values if the same data frame in other cells, I see old values only. Here is what I mean, for the following code:
for idx, row in cbis_ddsm_mass_test_df.iterrows():
old_img_path = row["image file path"]
patientID_and_img_view = old_img_path.split(os.path.sep)[0]
for new_file_path in cbis_ddsm_mass_test_png_paths:
if patientID_and_img_view in new_file_path:
print("CHANGING FROM {} -----> {}".format(cbis_ddsm_mass_test_df.loc[idx, "image file path"], new_file_path))
cbis_ddsm_mass_test_df.loc[idx, "image file path"] = new_file_path
print("NEW VALUE {}".format(cbis_ddsm_mass_test_df.loc[idx, "image file path"]))
I am getting following output:
...
CHANGING FROM Mass-Test_P_01741_LEFT_MLO/1.3.6.1.4.1.9590.100.1.2.427081021212301362442051465150709242679/1.3.6.1.4.1.9590.100.1.2.296864787312999692930337069052009530878/000000.dcm -----> /content/drive/My Drive/Breast Mammography/Full Mammogram Classifier/Data/CBIS_DDSM/numpy images/Mass-Test/Mass-Test_P_01741_LEFT_MLO_10-04-2016-DDSM-42679.png
NEW VALUE /content/drive/My Drive/Breast Mammography/Full Mammogram Classifier/Data/CBIS_DDSM/numpy images/Mass-Test/Mass-Test_P_01741_LEFT_MLO_10-04-2016-DDSM-42679.png
...
But, when I try to print first couple of values after "updating" DataFrame object, I actually see old values:
Strangely enough, I have THE EXACT SAME CODE for 3x more DataFrames
(I literally mean EXACT SAME SET OF CELLS), and it works just fine. Any thoughts?