Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 按熊猫中的布尔条件筛选CSV_Python_Pandas - Fatal编程技术网

Python 按熊猫中的布尔条件筛选CSV

Python 按熊猫中的布尔条件筛选CSV,python,pandas,Python,Pandas,我正在将CSV导入python并添加布尔条件,我只想显示布尔条件为true的行,有人能给我指出正确的方向吗就像furas说的,只需使用df[df==some_条件] e、 g 方向:pandas Documentation至少放置数据,这样我们可以帮助您更好地显示一些示例代码来显示问题。我希望你没有那么基本的问题可以解决print(df[df==some_condition])你试过什么?这就像熊猫101。 import pandas as pd df = pd.DataFrame({'A':

我正在将CSV导入python并添加布尔条件,我只想显示布尔条件为true的行,有人能给我指出正确的方向吗

就像furas说的,只需使用
df[df==some_条件]

e、 g


方向:pandas Documentation至少放置数据,这样我们可以帮助您更好地显示一些示例代码来显示问题。我希望你没有那么基本的问题可以解决
print(df[df==some_condition])
你试过什么?这就像熊猫101。
import pandas as pd

df = pd.DataFrame({'A':[1,2,3,4,5],'B':[True,False,True,False,False]})

print(df)

#filter for true
df = df[df['B']==True]

print(df)