contains

PANDAS Python | Contain specific value in specific position

PANDAS Python | Contain specific value in specific position Question: I’m trying to select just the rows that on the column "Cuenta" contain "05" in the third and fourth position , for example : 51050300 , 51050600 Año Periodo Cuenta 2023 1 51050300 2023 2 51053900 2023 1 74359570 2023 2 74452500 2023 6 51050300 …

Total answers: 3

How to check the string format of an entire column in Python using regex

How to check the string format of an entire column in Python using regex Question: I have Account Names which look like GH85036, LG95639, etc in a column. I want to check the format of the entire columns so I can edit the ones that don’t follow the format. This is my first time using …

Total answers: 1

Check if a substring is in a string python

Check if a substring is in a string python Question: I have two dataframe, I need to check contain substring from first df in each string in second df and get a list of words that are included in the second df First df(word): word apples dog cat cheese Second df(sentence): sentence apples grow on …

Total answers: 1

Python pandas how to update a column with value 1 if another column contains a certain word

Python pandas how to update a column with value 1 if another column contains a certain word Question: df looks like this: description and keybenefits (14) brand_cooltouch (1711) brand_easylogic (1712) Lorem Ipsum cooltouch Lorem Ipsum Lorem Ipsum easylogic Lorem Ipsum Lorem Ipsum Lorem Ipsum What I want: When column description and keybenefits (14) contains the …

Total answers: 3

Show which strings contained in a column

Show which strings contained in a column Question: How could I create the column called "reason", which shows which strings matched? match_d = {"col_a":["green", "purple"], "col_b":["weak", "stro", "strong"],…} df fruit col_a col_b 0 apple yellow NaN 1 pear blue NaN 2 banana green strong 3 cherry green heavy 4 grapes brown light … Expected Output …

Total answers: 1

Determine indexes where A is a submatrix of matrix B

Determine indexes where A is a submatrix of matrix B Question: I’m coding in python and I would like to know how I can get the indexes of a matrix A where the matrix B is contained in A. For example, if we have A = [[1,2,3], [4,5,6], [7,8,9]] and B = [[2,3], [5,6]] Then …

Total answers: 1

Re Search with regex (plain string match) applied to Pandas Dataframe column returns less results than the column length (Python)

Re Search with regex (plain string match) applied to Pandas Dataframe column returns less results than the column length (Python) Question: import re import pandas as pd df = pd.DataFrame({"Name": [‘match’, ‘1234match_sypid_1234_34_7’, ‘matchsypid_1234_56_7’, ‘Hellow’, ‘hello’, ‘oaoaooo’, ‘ciao’, ‘salut’,’sypid_09_2_3match’]}) print(df.shape) # => (9, 1) mask = [re.search(p,s) for p,s in zip(r"match", df[‘Name’])] print(len(mask)) # => 5 …

Total answers: 1

Pandas: Check if row exists with certain values

Pandas: Check if row exists with certain values Question: I have a two dimensional (or more) pandas DataFrame like this: >>> import pandas as pd >>> df = pd.DataFrame([[0,1],[2,3],[4,5]], columns=[‘A’, ‘B’]) >>> df A B 0 0 1 1 2 3 2 4 5 Now suppose I have a numpy array like np.array([2,3]) and want …

Total answers: 7