I want to filter a Pandas Series to remove certain values. This seems like such a simple task, but the preferred answer to the same question doesn't work for me.
Here's my reproducible example:
data = np.array([['','Col1','Col2'],
['Row1',1,2],
['Row2',3,4]])
myDF = pd.DataFrame(data=data[1:,1:],
index=data[1:,0],
columns=data[0,1:])
mySeries = myDF.loc[:, "Col1"]
mySeries[mySeries != 1]
I expect the final line to output a single row, containing the value 3, but instead I get:
Row1 1
Row2 3
Name: Col1, dtype: object
What am I doing wrong?