RangeIndex बनाने के लिए, pandas.RangeIndex() . का उपयोग करें पंडों में विधि। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import pandas as pd
RangeIndex, Int64Index का एक मेमोरी-सेविंग स्पेशल केस है, जो मोनोटोनिक रेंज का प्रतिनिधित्व करने तक सीमित है। RangeIndex का उपयोग करने से कुछ मामलों में कंप्यूटिंग गति में सुधार हो सकता है।
स्टार्ट, स्टॉप और स्टेप के साथ रेंज इंडेक्स बनाएं। नाम इंडेक्स में स्टोर होने वाला नाम है -
index = pd.RangeIndex(start=10, stop=30, step=2, name="data")
प्रारंभ पैरामीटर मान प्रदर्शित करें -
print("\nRangeIndex start value...\n",index.start) स्टॉप पैरामीटर मान प्रदर्शित करें -
print("\nRangeIndex stop value...\n",index.stop)
चरण पैरामीटर मान प्रदर्शित करें -
print("\nRangeIndex step value...\n",index.step) उदाहरण
निम्नलिखित कोड है -
import pandas as pd
# Create a range index with start, stop and step
# The name is the name to be stored in the index.
index = pd.RangeIndex(start=10, stop=30, step=2, name="data")
# Display the RangeIndex
print("RangeIndex...\n",index)
# Display the start parameter value
print("\nRangeIndex start value...\n",index.start)
# Display the stop parameter value
print("\nRangeIndex stop value...\n",index.stop)
# Display the step parameter value
print("\nRangeIndex step value...\n",index.step) आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
RangeIndex... RangeIndex(start=10, stop=30, step=2,name='data') RangeIndex start value... 10 RangeIndex stop value... 30 RangeIndex step value... 2