PANDAS SERIES – DIFFERENCE-BASED QUESTIONS (Class XII)

 

PANDAS SERIES – DIFFERENCE-BASED QUESTIONS (Class XII)




✍️ VERY SHORT / SHORT ANSWER (2–3 MARKS)

Q1. Difference between Pandas Series and Python List

FeaturePandas SeriesPython List
IndexingLabeled indexNo label, only position-based
Data typeCan store heterogeneous but usually single dtypeCan store heterogeneous
OperationsSupports vectorized operationsRequires loops for element-wise operations
Missing valuesCan handle NaNCannot handle NaN directly
MethodsBuilt-in statistical & data analysis functionsVery limited functions




Q2. Difference between loc[] and iloc[]

Featureloc[]iloc[]
Indexing         Label-based   Integer position-based
Slicing         Includes last element   Excludes last element
Example     s.loc['a']  s.iloc[0]

Q3. Difference between size and count()

Featuresizecount()
Counts       Total number of elements     Only non-NaN elements
Ignores NaN        No     Yes
Example    s.size → 5   s.count() → 4

Q4. Difference between fillna() and dropna()

Featurefillna()dropna()
Purpose      Replace missing values    Remove missing values
Modifies data      Yes    Yes
Example    s.fillna(0)   s.dropna()




Q5. Difference between unique() and value_counts()

Featureunique()value_counts()
Purpose      Returns unique values      Returns frequency of each value
Output type     Array      Series
Example   [10,20,30]    10:2, 20:3

Q6. Difference between head() and tail()

Featurehead()tail()
Purpose         Returns first n elements     Returns last n elements
Default n         5     5
Example     s.head(3)        s.tail(3)

Q7. Difference between Pandas Series and DataFrame

FeatureSeriesDataFrame
Dimension1-D2-D
IndexSingle indexRow and column index
Data typeUsually single dtypeCan have multiple dtypes
OperationsElement-wiseRow-wise & column-wise




Q8. Difference between s.index and s.values

Features.indexs.values
Purpose            Returns index labels         Returns data values
Type           Index object            NumPy array
Example      s.index → ['a','b','c']     s.values → [10,20,30]

Q9. Difference between isnull() and notnull()

Featureisnull()notnull()
Purpose     Checks for missing values     Checks for non-missing values
Output     Boolean Series     Boolean Series
Example       [True, False]   [False, True]






Q10. Difference between Pandas Series and DataFrame

FeaturePandas SeriesPandas DataFrame
DimensionOne-dimensional (1-D)Two-dimensional (2-D)
Data storageStores a single column of dataStores multiple columns of data (tabular form)
IndexSingle indexRow and column index
Data typeUsually stores a single data type (homogeneous)Can store multiple data types (heterogeneous)
RepresentationA single labeled arrayTable with rows and columns
OperationsElement-wise operationsCan perform row-wise and column-wise operations
Examplepd.Series([10,20,30], index=['a','b','c'])pd.DataFrame({'Name':['A','B'],'Marks':[90,85]})

Post a Comment

Please do note create link post in comment section

Previous Post Next Post