boolean

How to use boolean on list correctly?

How to use boolean on list correctly? Question: def check(A,B,a,b): return A >= a and B >= b A = [500, 500, 500] a = [20, 0, 0] B = [5, 5, 5, 5] b = [0, 10, 0, 0] print(check(A, B, a, b)) (result True) I want result become False if only one in …

Total answers: 1

How to remove lines of a textfile with a boolean as a rule in python?

How to remove lines of a textfile with a boolean as a rule in python? Question: I need to remove lines of a .txt file that start with certain values, say anything with a digit 0-9 or an !. I have already written a function noNumsExclam that looks something like this: def noNumsExclam(s: str) -> …

Total answers: 2

Is there a way to run a boolean if statement in Python Turtle?

Is there a way to run a boolean if statement in Python Turtle? Question: I’m editing a Turtle Pong template and realized that two paddles can’t move at the same time, so I’m trying to fix that bug by having it so, when a key is pressed, a boolean is set to true, and that …

Total answers: 1

check if values are between two values pandas

check if values are between two values pandas Question: I have a two values that are being found in a for loop like so: for i in range(df_zones.shape[0]): filter_max = df_labels[df_labels[‘Labels’] == i].sort_values(by=’level’).iloc[-1] filter_min = df_labels[df_labels[‘Labels’] == i].sort_values(by=’level’).iloc[0] I have another dataframe with 4 columns of measurements with a timeseries index, like so: DateTime meas1 …

Total answers: 2

creating new column based on condition (Python)

creating new column based on condition (Python) Question: I have a dataframe where one of the columns, "deals" is a TRUE/FALSE boolean. I want to create a new column that populates 1 when the "deals" column is True, and 0 when the "deals" columns is False. I tried the following code but it’s giving me …

Total answers: 2

Disjunction and membership in python

Disjunction and membership in python Question: When I try this code: a = [‘b’] if ‘i’ or ‘j’ in a: print(‘Yes!’) else: print(‘No!’) The output is ‘Yes!’. Flake8 and python do not complain about an error or bad form. What exactly happens when the code runs? Why does ‘i’ or ‘j’ in a evaluate as …

Total answers: 1

Is there a way to select interior True values for portions of a DataFrame?

Is there a way to select interior True values for portions of a DataFrame? Question: I have a DataFrame that looks like the following: df = pd.DataFrame({‘a’:[True]*5+[False]*5+[True]*5,’b’:[False]+[True]*3+[False]+[True]*5+[False]*4+[True]}) a b 0 True False 1 True True 2 True True 3 True True 4 True False 5 False True 6 False True 7 False True 8 False …

Total answers: 1

Convert STL object to VTK geometry in python

Convert STL object to VTK geometry in python Question: I am wanting to do Boolean operations on STL files with geometric primitives from the VTK library. My problem is converting the STL geometry to something that the VTK Boolean objects will except. I tried the following… import vtk filename = ‘gyroid.stl’ reader = vtk.vtkSTLReader() reader.SetFileName(filename) …

Total answers: 2