- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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.
Example 1
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)
Explanation
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”.
Output
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.
Example 2
import pandas as pd # create a series s = pd.Series(list("abcdef")) print(s) print("Is monotonically decreasing: ", s.is_monotonic_decreasing)
Explanation
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”.
Output
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.
- Related Articles
- 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?
- How to check each value of a pandas series is unique or not?\n
- How to use protractor to check whether text is present in an element or not?
- How to check whether a key exist in JavaScript object or not?
- How to check whether a data frame exists or not in R?
- Program to check whether one value is present in BST or not in Python
- How to check the data type of a pandas series?
- Check whether the Average Character of the String is present or not in Python
- How can we check if a JSON object is empty or not in Java?\n
- How to check if two data frames same or not in R?
- How to check if a value exists in an R data frame or not?
- Program to check three consecutive odds are present or not in Python
