I'm a newbie in python and trying to normalize each index in list using preprocessing.normalize. However, it gives me an error with ValueError: setting an array element with a sequence.
And then, I found what the problem was. It was because the length(size) of each index in np.array was different.
Here is my code,
result = []
for url in target_url :
sensor = pd.read_csv(url, header=None, delimiter=r"\s+")
result.append(sensor[2])
result = np.array(result)
# I want to resample here before it goes to normalize.
result = preprocessing.normalize(result, norm='l1')
I have target_url to get sensor data from webserver, and each appends to the result list. Then, it converts to array by using np.array
For example,
I have len(result[0]) has 121598 and len(result[1]) has 1215601. I want to make result[0] to be same length of result[1] using resample to fill NaN.
How can I do that?
Please help me out here.
Thanks in advance.
EDIT
After normalizing, I'm trying to do correlation using corr()
Here is the code,
result = preprocessing.normalize(result, norm='l1')
ret = pd.DataFrame(result)
corMat = DataFrame(ret.T.corr())