How to multiply pandas series by value?

I have a pandas series object and I want to multiply based on the value


s = pd.Series([1,2,3,4,5,6,7,8,9,10])


how can i multiply it so i can get a series object containing only elements of greater or lesser x value.


source to share

2 answers

I assume you are referring to boolean indexing in the series.

More x


x = 5
>>> s[s > x]  # Alternatively, s[].
5     6
6     7
7     8
8     9
9    10
dtype: int64


Less x

(i.e. below x):

s[s < x]  # or s[]




Assuming that by "large or by x

" you mean "not equal x

", you can use boolean indexing:





All Articles