python: remove specific values in a dataframe
df.drop(df.index[df['myvar'] == 'specific_name'], inplace = True)
python: remove specific values in a dataframe
df.drop(df.index[df['myvar'] == 'specific_name'], inplace = True)
remove all rows without a value pandas
# Keeps only rows without a missing value
df = df[df['name'].notna()]
pandas drop rows with value in list
import pandas as pd
a = ['2015-01-01' , '2015-02-01']
df = pd.DataFrame(data={'date':['2015-01-01' , '2015-02-01', '2015-03-01' , '2015-04-01', '2015-05-01' , '2015-06-01']})
print(df)
# date
#0 2015-01-01
#1 2015-02-01
#2 2015-03-01
#3 2015-04-01
#4 2015-05-01
#5 2015-06-01
df = df[~df['date'].isin(a)]
print(df)
# date
#2 2015-03-01
#3 2015-04-01
#4 2015-05-01
#5 2015-06-01
drop a row with a specific value of a column
df = df[df.line_race != 0]
pandas drop row from a list of value
df = df[~df.datecolumn.isin(a)]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us