0

I have problem with replace or change data in 2D array eg.

1   22-09-19    22:18   21.0    21.0    22.0    21.0    11.2
2   22-09-19    22:34   21.0    21.0    22.0    21.0    10.7
3   23-09-19    16:25   21.0    21.0    22.0    21.0    19.6
4   23-09-19    22:34   20.0    22.0    22.0    21.0    12.4
... ... ... ... ... ... ... ...
719 17/05/2020  22:00   23.0    25.0    23.0    26.0    11.4
720 18/05/2020  02:00   22.0    25.0    23.0    28.0    8.7
721 18/05/2020  08:00   22.0    24.0    22.0    26.0    15.4

and i want to change data string from '22-09-19' to '22/09/19'. I have a solution:

change_sep = lambda date: date.replace('-','/') if re.search(r'-', date) else date
for i, date in enumerate(correct_data[:,0]):
    correct_data[i,0] = change_sep(date=date)

but I think is not efficient and not clear. Thanks

0 Answers0