0
import numpy as np
contactangle = np.genfromtxt('/content/drive/My Drive/Colab Notebooks/Review_Vera/ContactAngle.csv', delimiter=',', names=True)
dielectricconstant = np.genfromtxt('/content/drive/My Drive/Colab Notebooks/Review_Vera/DielectricConstant.csv', delimiter=',', names=True)
specificgravity = np.genfromtxt('/content/drive/My Drive/Colab Notebooks/Review_Vera/SpecificGravity.csv', delimiter=',', names=True)
surfacetension = np.genfromtxt('/content/drive/My Drive/Colab Notebooks/Review_Vera/SurfaceTension.csv', delimiter=',', names=True)
print (contactangle)
ca = contactangle [1,:]
print (ca)

^^ That's my code and the error I get it.

That's my code and the error I get attached in the image. Essentially it print as a 2D array but says too many indices (ie. read as a 1D) when I try to select the second numerical column from the read array. It's super frustrating and outside of just typing out the array by hand I can't fix it

Error Message from image below:

[(1., 102.1) (2.,  96. ) (2.,  96. ) (3.,  87.4) (3.,  87.4) (3.,  87.4)
 (3.,  87.4) (4.,  85.6) (4.,  85.6) (4.,  85.6) (4.,  85.6) (5.,  72.5)
 (6.,  62.6) (6.,  62.6) (6.,  62.6) (7.,  71.1) (7.,  73. ) (7.,  78. )
 (7.,  87. ) (7.,  94.2)]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-15-54c3b7b1a0ec> in <module>()
      6 print (contactangle)
      7 ##import matplotlib.pyplot as plt
----> 8 ca = contactangle [1,:]
      9 print (ca)
     10 ##surfacetension = np.array ([30.5, 31.6, 31.6, 34., 34., 34., 34., 37.9, 37.9, 37.9, 37.9, 43.9, 43.9, 43.9])

IndexError: too many indices for array
leojames
  • 1
  • 1

0 Answers0