Reputation: 3557
I'm trying to figure out how to print a row given a known entry in a column within my data frame much like this question. However, this wasn't working for my DataFrame.
In [10]: df
Out[10:
A B C D
0 a b c d
1 t f h e
2 j r y k
In [11]: df[df['A'].str.contains('t')]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-11-618e00d5bb36> in <module>()
----> 1 df[df['A'].str.contains('t')]
AttributeError: 'Series' object has no attribute 'str'
Just to try and clarify my goal, say I know 't' is in my DataFrame somewhere and I also know it resides within column A, is there a search option that will print out the entire row it is located within?
Why am I getting this error?
Upvotes: 2
Views: 1634
Reputation: 375575
Vectorized string methods were introduced in pandas 0.9 (so it isn't available as a Series method in version you're using: 0.8). Refresh your pandas to the latest stable version for the latest and greatest features.
Upvotes: 1