will be helpful for those in need You can use .loc create a sub dataframe with all of the assignment values. You then use isin together with all to identify which contain all of the target test values (specifying axis=1 for rows).
I wish this helpful for you I have a huge dataframe with 4998 columns, column headers are the name of the companies. These columns contain stock prices as values in the column. So, I want to remove penny stocks that is price of stock(value in columns) less than 1.So, I want to remove the whole column if its values are less than 1. Additionally, there are columns in the data frame where the values fluctuate they go below 1 but then come back equal or greater to 1, in this scenerio I want in this column when value is below 1 it be replaced by NA. I have referred to 'Replace multiple values in multiple columns of dataframes with values in another column' but my case is bit different. I illustrate a small part of data frame , Here's a similar approach (perhaps more vectorized?)
is.na(df[-1]) <- df[-1] < 1 # Convert all values < 1 to NAs.
df[colSums(is.na(df)) != nrow(df)] # Select only the columns that have values.
# Date A C
# 1 01/01/2000 NA NA
# 2 02/01/2000 NA NA
# 3 03/01/2000 NA NA
# 4 04/01/2000 NA NA
# 5 05/01/2000 5 NA
# 6 06/01/2000 6 1
# 7 07/01/2000 7 1
# 8 08/01/2000 8 NA
# 9 09/01/2000 9 NA
hop of those help? I've searched far and wide for a solution to my problem... over several long weeks now. I've come up a partially working solutions, which I'll include at the bottom for those who might know how to modify/extend them to resolve the problem. , Sample Data solution