I'm trying to change a matrix of numbers from string to integer but it just doesn't work.
for element in list: for i in element: i = int(i)
What am I doing wrong?
Edit: This is the whole code:
import numpy as np t_list = [] t_list = np.array(t_list) list_rains_per_months = [['63', '65', '50', '77', '66', '69'], ['65', '65', '67', '50', '54', '58'], ['77', '73', '80', '83', '89', '100'], ['90', '85', '90', '90', '84', '90'], ['129', '113', '120', '135', '117', '130'], ['99', '116', '114', '111', '119', '100'], ['105', '98', '112', '113', '102', '100'], ['131', '120', '111', '141', '130', '126'], ['85', '101', '88', '89', '94', '91'], ['122', '103', '119', '98', '101', '107'], ['121', '101', '104', '121', '115', '104'], ['67', '44', '58', '61', '64', '58']] for element in t_list: for i in element: i = int(i)
I apologize for any mistakes, I'm new to python
https://stackoverflow.com/questions/66094216/convert-a-matrix-from-string-to-integer February 08, 2021 at 07:29AM
没有评论:
发表评论