Computer >> कंप्यूटर >  >> प्रोग्रामिंग >> Python

पायथन पांडा - सूचकांक का स्थानांतरण लौटाएं

अनुक्रमणिका के स्थानान्तरण को वापस करने के लिए, index.T . का उपयोग करें संपत्ति।

सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -

import pandas as pd

अनुक्रमणिका बनाना -

index = pd.Index(['Car','Bike','Truck','Ship','Airplane'])

सूचकांक प्रदर्शित करें -

print("Pandas Index...\n",index)

सूचकांक का स्थानान्तरण प्रदर्शित करें -

print("\nTranspose of the Pandas Index which is by definition self...\n",index.T)

उदाहरण

निम्नलिखित कोड है -

import pandas as pd

# Creating the index
index = pd.Index(['Car','Bike','Truck','Ship','Airplane'])

# Display the index
print("Pandas Index...\n",index)

# Return an array representing the data in the Index
print("\nArray...\n",index.values)

# Display the transpose of the index
print("\nTranspose of the Pandas Index which is by definition self...\n",index.T)

आउटपुट

यह निम्नलिखित कोड उत्पन्न करेगा -

Pandas Index...
Index(['Car', 'Bike', 'Truck', 'Ship', 'Airplane'], dtype='object')

Array...
['Car' 'Bike' 'Truck' 'Ship' 'Airplane']

Transpose of the Pandas Index which is by definition self...
Index(['Car', 'Bike', 'Truck', 'Ship', 'Airplane'], dtype='object')

  1. पायथन - पंडों के सूचकांक का अधिकतम मूल्य लौटाएं

    पांडा सूचकांक का अधिकतम मूल्य वापस करने के लिए, index.max() . का उपयोग करें तरीका। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें - import pandas as pd पांडा इंडेक्स बनाना index = pd.Index([10, 20, 70, 40, 90, 50, 25, 30]) पांडा सूचकांक प्रदर्शित करें - print("Pandas Index...\n",index) अधि

  1. पायथन - पंडों के सूचकांक का न्यूनतम मूल्य लौटाएं

    पांडा इंडेक्स का न्यूनतम मान वापस करने के लिए, index.min() . का उपयोग करें तरीका। सबसे पहले, आवश्यक पुस्तकालयों को आयात करें - import pandas as pd पांडा इंडेक्स बनाना - index = pd.Index([10.5, 20.4, 40.5, 25.6, 5.7, 6.8, 30.8, 50.2]) पांडा सूचकांक प्रदर्शित करें - print("Pandas Index...\n&qu

  1. पायथन पांडा - इंटरवलएरे में प्रत्येक अंतराल के मध्य बिंदु को एक सूचकांक के रूप में लौटाएं

    इंडेक्स के रूप में इंटरवलएरे में प्रत्येक अंतराल के मध्य बिंदु को वापस करने के लिए, array.mid का उपयोग करें संपत्ति। सबसे पहले, सबसे पहले, आवश्यक पुस्तकालयों को आयात करें - import pandas as pd दो इंटरवल ऑब्जेक्ट बनाएं। दोनों मान के साथ बंद पैरामीटर का उपयोग करके सेट किए गए बंद अंतराल - interval1 =