相关疑难解决方法(0)

根据pandas中列的值从DataFrame中选择行

如何根据pandas中某些列中的值从DataFrame中选择行?
在SQL中我会使用:

SELECT *
FROM table
WHERE colume_name = some_value
Run Code Online (Sandbox Code Playgroud)

我试着看看熊猫文档,但没有立即找到答案.

python dataframe pandas

1649
推荐指数
15
解决办法
230万
查看次数

根据pandas中多列中的值从Dataframe中选择行

这个问题与另一个问题非常相关,我甚至会在这个问题上使用非常有用的解决方案中的例子.以下是已接受的解决方案(信用证到unutbu)的示例:

import pandas as pd
import numpy as np
df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(),
                   'B': 'one one two three two two one three'.split(),
                   'C': np.arange(8), 'D': np.arange(8) * 2})
print(df)
#      A      B  C   D
# 0  foo    one  0   0
# 1  bar    one  1   2
# 2  foo    two  2   4
# 3  bar  three  3   6
# 4  foo    two  4   8
# 5  bar    two  5 …
Run Code Online (Sandbox Code Playgroud)

python pandas

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

pandas ×2

python ×2

dataframe ×1