Tag: conditions:
C++11 Multithreading – Part 4: Data Sharing and Race Conditions
In multithreading environment data sharing between threads is very easy. But this easy sharing of data can cause problems in application. One such problem is Race Condition. What is a Race Condition? Race condition is a kind of a bug that occurs in multithreaded applications. Advertisements When two or more threads perform a set of …
C++11 Multithreading – Part 4: Data Sharing and Race ConditionsRead More
C++11 Multithreading – Part 5: Using mutex to fix Race Conditions
In this article we will discuss how to use mutex locks to protect shared data in multithreaded environment and avoid race conditions. To fix race conditions in multi-threaded environment we need mutex i.e. each thread needs to lock a mutex before modifying or reading the shared data and after modifying the data each thread should …
C++11 Multithreading – Part 5: Using mutex to fix Race ConditionsRead More
Pandas – Select Rows by conditions on multiple columns
In this article we will discuss different ways to select rows in DataFrame based on condition on single or multiple columns. Following Items will be discussed, Advertisements Select Rows based on value in column Select Rows based on any of the multiple values in column Select Rows based on any of the multiple conditions on …
Pandas – Select Rows by conditions on multiple columnsRead More
Python Pandas : How to Drop rows in DataFrame by conditions on column values
In this article we will discuss how to delete rows based in DataFrame by checking multiple conditions on column values. DataFrame provides a member function drop() i.e. Advertisements DataFrame.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors=’raise’) It accepts a single or list of label names and deletes the corresponding rows or columns (based on value of axis …
Python Pandas : How to Drop rows in DataFrame by conditions on column valuesRead More
Python : Filter a dictionary by conditions on keys or values
In this article we will discuss different ways to filter contents from a dictionary by conditions on keys or value or on both. Suppose we have a dictionary in which int type element is key and string type elements are value i.e. Advertisements dictOfNames = { 7 : ‘sam’, 8: ‘john’, 9: ‘mathew’, 10: ‘riti’, …
Python : Filter a dictionary by conditions on keys or valuesRead More
Delete elements from a Numpy Array by value or conditions in Python
In this article we will discuss different ways to delete elements from a Numpy Array by matching value or based on multiple conditions. Remove all occurrences of an element with given value from numpy array Suppose we have a numpy array of numbers i.e. Advertisements # Create a numpy array from a list arr = …
Delete elements from a Numpy Array by value or conditions in PythonRead More
Python : Count elements in a list that satisfy certain conditions
In this example we will discuss 4 different ways to count number of elements in a list that satisfy certain conditions. Suppose we have a list of numbers i.e. Advertisements # List of numbers listOfElems = [11, 22, 33, 45, 66, 77, 88, 99, 101] We want to count number of elements in the list …
Python : Count elements in a list that satisfy certain conditionsRead More
Pandas: Select columns based on conditions in dataframe
In this article, we will discuss how to select dataframe columns based on conditions i.e. either a single condition or multiple conditions. Let’s start this with creating a dataframe first, import pandas as pd # List of Tuples empoyees = [(11, 34, 78, 5, 11, 56), (12, 31, 98, 7, 34, 78), (13, 16, 11, …
Pandas: Select columns based on conditions in dataframeRead More
Multiline conditions with ‘if’ statements in Python
In this Python tutorial, we will learn how to style multi-line conditions in ‘if’ statements in Python. Agenda Multi-line conditions in ‘if’ statements with brackets Multi-line conditions in ‘if’ statements without brackets Summary Let’s dive into the tutorial. Advertisements Multi-line conditions in ‘if’ statements with brackets If you are using brackets around if statements, then …
Multiline conditions with ‘if’ statements in PythonRead More
Replace column values based on conditions in Pandas
In this article, we will discuss various methods to replace the column values based on conditions in a pandas DataFrame. Let’s look at the table of contents describing the list of methods. Table of Contents Preparing DataSet Method 1: Using .loc property of DataFrame Method 2: Using numpy.where() method Method 3: Using DataFrame.where() method Method …
Replace column values based on conditions in PandasRead More