0

'car3.csv' file download link

import csv
num = open('car3.csv')
nums = csv.reader(num)
nums_list = []
for i in nums:
    nums_list.append(i)

import numpy as np
nums_arr = np.array(nums_list, dtype = np.float32)
print(nums_arr)
print(np.std(nums_arr, axis=0))

The result is this.


[[ 1.  1.  2.]
 [ 1.  1.  2.]
 [ 1.  1.  2.]
 ..., 
 [ 0.  0.  5.]
 [ 0.  0.  5.]
 [ 0.  0.  5.]]
[ 0.5         0.5         1.11803401]

There are lots of spaces that I didn't expected. How can I handle these anyway?

hyeok9855
  • 11
  • 2

1 Answers1

0

That is not a spacing problem. What all you need to do is to save the output of the standard deviation. Then, you can access each value like this:

 std_arr = np.std(nums_arr, axis=0) # array which holds std of each column

 # now, you can access them by indexing: 
 print(std_arr[0]) # output here is 0.5
 print(std_arr[1]) # output here is 0.5
 print(std_arr[2]) # output here is 1.118034
Sanchit
  • 3,180
  • 8
  • 37
  • 53