Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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?

share|improve this question
    
can you add output of up3.head( ) to your question? – behzad.nouri Dec 16 '13 at 13:44
    
up3.head() gives me the rows 1 to 5 of the data – user3087409 Dec 16 '13 at 13:55
    
Are you sure that data in your frames is numeric? When i wrote your file it was strings because of first(second) row – Andrey Shokhin Dec 16 '13 at 13:58
    
@AndreyShokhin I think that's the problem. My data is of the form -130.9780E-06 (for example) and I can plot it when I convert it to floats, but I lose precision. Although I don't think this explains why I can plot up2. – user3087409 Dec 16 '13 at 14:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.