Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas find value in any column

#This syntax shows how to select all rows of the DataFrame that contain the values 25, 9
#in any of the columns:
df[df.isin([25, 9]).any(axis=1)]
Comment

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

pandas search value in column contains

# For columns of string elements, searching if it contains the word. 
# Case insensitive

df.loc[df['column_name'].str.contains("search_word", case=False)] 
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

PREVIOUS NEXT
Code Example
Python :: python program to add two numbers 
Python :: python datetime get all days between two dates 
Python :: describe function in pandas 
Python :: drop missing values in a column pandas 
Python :: difference between 2 timestamps pandas 
Python :: pandas dataframe column names 
Python :: check if part of list is in another list python 
Python :: print str and float python 
Python :: python list .remove() in for loop breaks 
Python :: pyttsx3 female voice template 
Python :: numpy drop duplicates 
Python :: python get response from url 
Python :: df index start from 1 
Python :: case insensitive replace python 
Python :: python execute shell command and get output 
Python :: pandas xlsx to dataframe 
Python :: convert string to list of dictionaries 
Python :: if string contains list of letters python 
Python :: networkx path between two nodes 
Python :: django order by 
Python :: module installed but not found python 
Python :: how to download the captions of a youtube video 
Python :: pyspark join 
Python :: how to write to a netcdf file using xarray 
Python :: outliers removal pandas 
Python :: convert string to dictionary python 
Python :: playsound error 
Python :: create dictionary from input python 
Python :: python run command and read output 
Python :: python input function 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =