Which function should be used to get first n rows of a dataframe?
2025
Which function should be used to get first n rows of a dataframe?
- A.
print(n)
- B.
head(n)
- C.
get(n)
- D.
call(n)
Attempted by 1066 students.
Show answer & explanation
Correct answer: B
To get the first n rows of a dataframe, the correct function is 'head(n)'. This function is specifically designed to return the top n rows of a dataframe in data analysis tools like pandas.
The function 'print(n)' is used to display values, not to extract rows from a dataframe. It does not operate on the dataframe structure.
The function 'get(n)' is not a standard method for accessing rows in a dataframe. It is not recognized in common data analysis libraries.
The function 'call(n)' is not used for retrieving rows. It is not a valid function for dataframe operations.
हिन्दी उत्तर: डेटा फ्रेम की पहली n पंक्तियाँ प्राप्त करने के लिए 'head(n)' फ़ंक्शन का उपयोग किया जाता है। यह फ़ंक्शन डेटा फ्रेम के शीर्ष n पंक्तियों को वापस करने के लिए विशेष रूप से डिज़ाइन किया गया है।
फ़ंक्शन 'print(n)' का उपयोग निर्दिष्ट मानों को प्रदर्शित करने के लिए किया जाता है, डेटा फ्रेम से पंक्तियों को प्राप्त करने के लिए नहीं। यह डेटा फ्रेम संरचना पर कोई ऑपरेशन नहीं करता है।
फ़ंक्शन 'get(n)' डेटा फ्रेम की पंक्तियों को एक्सेस करने के लिए मानक विधि नहीं है। यह सामान्य डेटा विश्लेषण लाइब्रेरी में पहचाना नहीं जाता है।
फ़ंक्शन 'call(n)' पंक्तियों को प्राप्त करने के लिए उपयोग नहीं किया जाता है। यह डेटा फ्रेम ऑपरेशन्स के लिए एक वैध फ़ंक्शन नहीं है।