0

I'm trying to split a pandas DataFrame into two and then plot the two halves, but I'm encountering an error when I try to plot.

The data I'm testing my code on is here.

It's a DataFrame with a row of titles, a row of units, and then data with a one row gap half-way down filled with NaN (just the way the data is stored).

I import the data with

up = pd.read_csv(filename, delim_whitespace=False, skipinitialspace=True)

The first row with titles gets read as the column names. It can't be plotted yet because of the row with the units in, so I remove the first row with up2 = up[1:].

Now, I want to split the data where the row of NaN occurs, so I've defined a function cutting that returns the row where the NaN occur - cut_loc = cutting(up2).

Now I apply the cut: up3 = up2[:cut_loc-1], which should just shorten the DataFrame. However, when I go to plot it up3.plot(x='Field', y='Moment', color='red', label='Up' I get the error 'numpy.ndarray' object has no attribute 'find'

I can plot up2, but not up (because of the row of units) or up3. I can't see why. Anyone know?

Ray
  • 2,472
  • 18
  • 22
thosphor
  • 2,493
  • 7
  • 26
  • 42

0 Answers0