यदि सूचकांक मोनोटोनिक घटते (केवल बराबर या घटते) मान है, तो लौटने के लिए, index.is_monotonic_decreeasing का उपयोग करें संपत्ति।
सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
अनुक्रमणिका बनाना -
index = pd.Index([50, 40, 30, 30, 30])
सूचकांक प्रदर्शित करें -
print("Pandas Index...\n",index) जांचें कि क्या सूचकांक मोनोटोनिक घट रहा है -
print("\nIs the Pandas index monotonic decreasing?\n",index.is_monotonic_decreasing)
उदाहरण
निम्नलिखित कोड है -
import pandas as pd
# Creating the index
index = pd.Index([50, 40, 30, 30, 30])
# Display the index
print("Pandas Index...\n",index)
# Return an array representing the data in the Index
print("\nArray...\n",index.values)
# Check if the index monotonic decreasing
print("\nIs the Pandas index monotonic decreasing?\n",index.is_monotonic_decreasing) आउटपुट
यह निम्नलिखित कोड उत्पन्न करेगा -
Pandas Index... Int64Index([50, 40, 30, 30, 30], dtype='int64') Array... [50 40 30 30 30] Is the Pandas index monotonic decreasing? True