0

I'm currently trying to learn Python and Numpy. The task is to determine the length of individual columns of an imported CSV file.

So far I have:

import numpy as np
data = np.loadtxt("assignment5_data.csv", delimiter = ',')
print (data.shape[:])

Which returns:

(62, 2)

Is there a way to iterate through each column to count [not is.nan]?

Brandon
  • 1
  • 1

1 Answers1

0

If I understand correctly, and you are trying to get the length of non-nan values in each column, use:

np.sum(~np.isnan(data),axis=0)
sacuL
  • 49,704
  • 8
  • 81
  • 106