Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find record where dataframe column value contains

import pandas as pd

data = {'Month': ['January','February','March','April','May','June','July','August','September','October','November','December'],
        'Days in Month': [31,28,31,30,31,30,31,31,30,31,30,31]
        }

df = pd.DataFrame(data, columns = ['Month', 'Days in Month'])

contain_values = df[df['Month'].str.contains('Ju')]
print (contain_values)
Comment

finding the rows in a dataframe where column contains any of these values python

import pandas as pd

data = {'Month': ['January','February','March','April','May','June','July','August','September','October','November','December'],
        'Days in Month': [31,28,31,30,31,30,31,31,30,31,30,31]
        }

df = pd.DataFrame(data, columns = ['Month', 'Days in Month'])

contain_values = df[df['Month'].str.contains('Ju')]
print (contain_values)
Comment

pandas check if any of the values in one column exist in another

df["exists"] = df.drop("target", 1).isin(df["target"]).any(1)
print(df)

    target  A       B       C       exists
0   cat     bridge  cat     brush   True
1   brush   dog     cat     shoe    False
2   bridge  cat     shoe    bridge  True
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib position legend 
Python :: python color input 
Python :: TypeError: strptime() argument 1 must be str, not Series 
Python :: how to add rows to empty dataframe 
Python :: rename columns 
Python :: check if host is reachable python 
Python :: scroll down selenium python 
Python :: flask error 
Python :: how to check if a input is an integer python 
Python :: python binary remove 0b 
Python :: hex python add 0 
Python :: work with gzip 
Python :: python turtle get mouse position 
Python :: python telethon 
Python :: python list unique in order 
Python :: calculate the same value in list i python 
Python :: turn false true column into 0 1 pandas 
Python :: valor absoluto en python 
Python :: how to delete a variable python 
Python :: how to count backwards in for loop python 
Python :: python random liste 
Python :: python line_profiler 
Python :: plot second axis plotly 
Python :: otp generation in python 
Python :: How to load .mat file and convert it to .csv file? 
Python :: mario cs50 
Python :: pandas rename column values dictionary 
Python :: how to count the occurrence of a word in string python 
Python :: pandas length of dataframe 
Python :: string to bits python 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =