Answers for "if row contains pandas"

4

filter by row contains pandas

In [3]: df[df['ids'].str.contains("ball")]  # removes all rows where 'ball' not in row['ids']
Out[3]:
     ids  vals
0  aball     1
1  bball     2
3  fball     4
Posted by: Guest on April-21-2020
0

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)
Posted by: Guest on June-13-2021

Code answers related to "if row contains pandas"

Python Answers by Framework

Browse Popular Code Answers by Language