कॉलम के डेटाटाइप प्राप्त करने के लिए, info() मेथड का उपयोग करें। सबसे पहले आवश्यक लाइब्रेरी इम्पोर्ट करें –
import pandas as pd
अलग-अलग डेटाटाइप वाले 2 कॉलम के साथ डेटाफ्रेम बनाएं –
dataFrame = pd.DataFrame(
{
"Student": ['Jack', 'Robin', 'Ted', 'Marc', 'Scarlett', 'Kat', 'John'],
"Roll Number": [5, 10, 3, 8, 2, 9, 6]
}
)
डेटाटाइप के बारे में पूरी जानकारी प्राप्त करें –
dataFrame.info()
उदाहरण
निम्न पूर्ण कोड है –
import pandas as pd
# डेटाफ्रेम बनाएं
dataFrame = pd.DataFrame(
{
"Student": ['Jack', 'Robin', 'Ted', 'Marc', 'Scarlett', 'Kat', 'John'],
"Roll Number": [5, 10, 3, 8, 2, 9, 6]
}
)
print "DataFrame ...\n", dataFrame
print "\nInfo and the datatypes of the columns in the dataframe:\n"
# डेटाटाइप जानकारी प्राप्त करें
print(dataFrame.info())
आउटपुट
यह निम्न आउटपुट उत्पन्न करेगा –
DataFrame ... Roll Number Student 0 5 Jack 1 10 Robin 2 3 Ted 3 8 Marc 4 2 Scarlett 5 9 Kat 6 6 John Info and the datatypes of the columns in the dataframe:RangeIndex: 7 entries, 0 to 6 Data columns (total 2 columns): Roll Number 7 non-null int64 Student 7 non-null object dtypes: int64(1), object(1) memory usage: 184.0+ bytes None