- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check the data present in a Series object is monotonically decreasing or not?
To check if the data present in the series is monotonically decreasing or not, we can use the is_monotonic_decreasing property of the pandas Series constructor.
The monotonically decreasing data is nothing but continuously decreasing values. And the attribute “is_monotonic_decreasing” is used to verify that the data in a given series object is always decreasing or not. And this attribute returns a boolean value as an output.
import pandas as pd # create a series s = pd.Series([100,57,23,10,5]) print(s) print("Is monotonically decreasing: ", s.is_monotonic_decreasing)
Here, we initialized a Series with a python list of integer values of length 5. Then we applied the is_monotonic_decreasing property on our series object “s”.
0 100 1 57 2 23 3 10 4 5 dtype: int64 Is monotonically decreasing: True
In the above output, we can see the initial series object, and also the output of the is_monotonic_decreasing attribute.
For the following example, The is_monotonic_decreasing attribute returns True. which means the data in the given series is continuously decreasing.
import pandas as pd # create a series s = pd.Series(list("abcdef")) print(s) print("Is monotonically decreasing: ", s.is_monotonic_decreasing)
Let’s take another example for checking if the values in a series object is monotonically decreasing or not. Here, we have initialized a series object with a python list of strings. After that, we applied the is_monotonic_decreasing property over the data of the series object “s”.
0 a 1 b 2 c 3 d 4 e 5 f dtype: object Is monotonically decreasing: False
We got the boolean value “False” as a result of the following example. which means that the values present in the given series object is not decreasing continuously.
- How to check the data present in a Series object is monotonically increasing or not?
- PHP program to check if a given number is present in an infinite series or not
- How to check whether the Pandas series is having Nan values or not?
- How to check in R whether a matrix element is present in another matrix or not?
- Check whether the Average Character of the String is present or not in Python
- How to check each value of a pandas series is unique or not?\n
- Program to check whether one value is present in BST or not in Python
- How can we check if a JSON object is empty or not in Java?
- Program to check three consecutive odds are present or not in Python
- How to check whether a data frame exists or not in R?
- What happens if the specified index is not present in the series Python Pandas?
- How to check the data type of a pandas series?
- In MySQL, how to check for a pattern which is not present within an expression?