The code below has to update test_df dataframe, which is currently filled with NaNs.
Each 'dig' (which is always an integer) value has corresponding 'top', 'bottom', 'left' and 'right' values, and the slices of dataframe, corresponding to respective top:bottom, left:right ranges for each 'dig', need to be updated with 'dig' values.
For example, if dig=9, top=2, botton=4, left=1 and right=5, all the NaNs within the range of 2:4, 1:5 need to be replaced with 9s.
The following code reports no errors, however, no NaNs are being updated.
for index, row in letters_df.iterrows():
    dig = str(row[0])
    top = int(height) - int(row[2])
    bottom = int(height) - int(row[4])
    left = int(row[1])
    right = int(row[3])
    test_df.iloc[top:bottom, left:right] = dig
test_df:
   0    1    2    3    4    5    6    ...  633  634  635  636  637  638  639
0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN  NaN  NaN  NaN
1  NaN  NaN  NaN  NaN  NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN  NaN  NaN  NaN
2  NaN  NaN  NaN  NaN  NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN  NaN  NaN  NaN
3  NaN  NaN  NaN  NaN  NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN  NaN  NaN  NaN
4  NaN  NaN  NaN  NaN  NaN  NaN  NaN  ...  NaN  NaN  NaN  NaN  NaN  NaN  NaN
letters_df:
   0    1    2    3    4  5  dig_unique_letters
0  T   36  364   51  388  0                   0
1  h   36  364   55  388  0                   1
2  i   57  364   71  388  0                   2
3  s   76  364   96  388  0                   3
4  i  109  364  112  388  0                   2
 
     
    