I need remove some rows for a DataFrame like this:
import pandas as pd
import numpy as np
input_ = pd.DataFrame()
input_ ['ID'] = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
input_ ['ST'] = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]
input_ ['V'] = [NaN, NaN, 1, 1, NaN, 1, Nan, 1, NaN, NaN, NaN, NaN]
\
And finish with a DataFrame like this one:
output_ ['ID'] = [ 2, 3, 4, 2, 3, 4, 2, 3, 4]
output_ ['ST'] = [ 1, 1, 1, 2, 2, 2, 3, 3, 3]
output_ ['V'] = [NaN, 1, 1, 1, Nan, 1, NaN, NaN, NaN]
Where, I had removed the rows with ID == 1, because, this rows have the column V == float(NaN) [np.isnan(V)] for ALL values in the column ST. How should I selec which rows I erase in Pandas DataFrame with this two conditions?.
https://stackoverflow.com/questions/66501877/how-should-i-selec-which-rows-i-erase-in-pandas-dataframe-with-a-two-conditions March 06, 2021 at 10:43AM
没有评论:
发表评论