Python 矢量化数据帧?

Python 矢量化数据帧?,python,pandas,Python,Pandas,我正试图弄清楚如何在数据框中的列中给定已知条目打印行,这和问题很相似。然而,这对我的数据帧不起作用 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')] -----------------------------------------------------------------------

我正试图弄清楚如何在数据框中的列中给定已知条目打印行,这和问题很相似。然而,这对我的数据帧不起作用

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'
[10]中的
:df
出[10:
A、B、C、D
0 a b c d
1 t f h e
2 j r y k
在[11]中:df[df['A'].str.contains('t')]
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在()
---->1 df[df['A'].str.contains('t')]
AttributeError:“Series”对象没有属性“str”
为了明确我的目标,假设我知道“t”在我的数据框中的某个地方,并且我也知道它位于A列中,是否有一个搜索选项可以打印出它所在的整行


为什么我会出现此错误?

是(因此在您使用的版本:0.8中,它不能作为系列方法提供)。请将您的pandas刷新到以获取最新和最强大的功能。

df[df['a'].str.contains(“t”)]
以何种方式显示(
df[df['a']].str.contains(“t”)])
(来自该问题)不起作用??删除答案的评论显示,这不起作用,因为OP使用的是旧版本的pandas(0.8),升级(到0.11)修复了它。