Python: Usuń określone wartości w ramce danych
df.drop(df.index[df['myvar'] == 'specific_name'], inplace = True)
Andrea Perlato
df.drop(df.index[df['myvar'] == 'specific_name'], inplace = True)
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
def filter_rows_by_values(df, col, values):
return df[~df[col].isin(values)]
df = df[df.line_race != 0]