Q1. What is a DataFrame?
A DataFrame is a 2D labeled data structure with rows and columns.
Q2. How to create a DataFrame?
pd.DataFrame(data)
Q3. How to view first rows?
df.head()
Q4. How to view last rows?
df.tail()
Q5. How to get shape of DataFrame?
df.shape
Q6. How to get column names?
df.columns
Q7. How to get index?
df.index
Q8. How to get summary info?
df.info()
Q9. How to describe data?
df.describe()
Q10. How to check data types?
df.dtypes
Q11. Select single column?
df['col']
Q12. Select multiple columns?
df[['col1','col2']]
Q13. Select rows using loc?
df.loc[0]
Q14. Select rows using iloc?
df.iloc[0]
Q15. Difference between loc and iloc?
loc uses labels, iloc uses index positions.
Q16. Boolean filtering?
df[df['col'] > 10]
Q17. Select specific rows and columns?
df.loc[0:2, 'col']
Q18. Get unique values?
df['col'].unique()
Q19. Count unique values?
df['col'].nunique()
Q20. Value counts?
df['col'].value_counts()
Q21. Check missing values?
df.isnull()
Q22. Drop missing values?
df.dropna()
Q23. Fill missing values?
df.fillna(0)
Q24. Remove duplicates?
df.drop_duplicates()
Q25. Rename columns?
df.rename(columns={'old':'new'})
Q26. Change data type?
df['col'] = df['col'].astype(int)
Q27. Replace values?
df.replace(1,100)
Q28. Strip spaces?
df['col'].str.strip()
Q29. Convert to lowercase?
df['col'].str.lower()
Q30. Detect duplicates?
df.duplicated()
Q31. Add new column?
df['new'] = value
Q32. Delete column?
df.drop('col', axis=1)
Q33. Sort values?
df.sort_values('col')
Q34. Sort index?
df.sort_index()
Q35. Apply function?
df['col'].apply(func)
Q36. Map function?
df['col'].map(dict)
Q37. Lambda function?
df['col'].apply(lambda x: x+1)
Q38. Conditional column?
df['new'] = df['col'] > 10
Q39. Set index?
df.set_index('col')
Q40. Reset index?
df.reset_index()
Q41. Group data?
df.groupby('col')
Q42. Group and sum?
df.groupby('col').sum()
Q43. Group and mean?
df.groupby('col').mean()
Q44. Multiple aggregation?
df.groupby('col').agg(['sum','mean'])
Q45. Count in group?
df.groupby('col').count()
Q46. Merge DataFrames?
pd.merge(df1, df2, on='col')
Q47. Inner join?
merge(..., how='inner')
Q48. Outer join?
merge(..., how='outer')
Q49. Left join?
merge(..., how='left')
Q50. Right join?
merge(..., how='right')
Q51. Read CSV?
pd.read_csv('file.csv')
Q52. Write CSV?
df.to_csv('file.csv')
Q53. Read Excel?
pd.read_excel('file.xlsx')
Q54. Write Excel?
df.to_excel('file.xlsx')
Q55. Pivot table?
pd.pivot_table(df, values='col', index='col1')
Q56. Crosstab?
pd.crosstab(df['a'], df['b'])
Q57. Rolling mean?
df['col'].rolling(3).mean()
Q58. Shift data?
df.shift(1)
Q59. Ranking?
df['col'].rank()
Q60. Sampling?
df.sample(5)
Q61. What is MultiIndex in Pandas?
MultiIndex allows multiple levels of indexing in rows or columns.
Q62. How to create MultiIndex?
pd.MultiIndex.from_tuples()
Q63. What is stack()?
Converts columns into rows.
Q64. What is unstack()?
Converts rows into columns.
Q65. What is explode()?
Expands list-like elements into separate rows.
Q66. What is query()?
Used to filter data using string expressions.
Q67. Example of query()?
df.query('col > 10')
Q68. What is eval()?
Evaluates expressions in DataFrame.
Q69. Example of eval()?
df.eval('C = A + B')
Q70. What is memory optimization?
Reducing memory usage by changing data types.
Q71. How to optimize memory?
df['col'] = df['col'].astype('int8')
Q72. What is vectorization?
Applying operations on entire arrays without loops.
Q73. Why vectorization is faster?
Because it uses optimized C-level operations.
Q74. String operations in Pandas?
df['col'].str.upper()
Q75. Extract substring?
df['col'].str[:3]
Q76. Replace string values?
df['col'].str.replace('a','b')
Q77. DateTime conversion?
pd.to_datetime(df['date'])
Q78. Extract year from date?
df['date'].dt.year
Q79. Extract month?
df['date'].dt.month
Q80. What is resampling?
Changing frequency of time-series data.
Q81. Example of resampling?
df.resample('M').sum()
Q82. What is rolling window?
Applies functions over moving window.
Q83. Example of rolling?
df['col'].rolling(3).mean()
Q84. What is expanding?
Cumulative calculations.
Q85. Example expanding?
df['col'].expanding().sum()
Q86. What is applymap()?
Applies function to entire DataFrame.
Q87. Difference apply vs map?
apply works on Series/DataFrame, map on Series only.
Q88. What is pipe()?
Used for chaining functions.
Q89. Handling large datasets?
Use chunking or Dask.
Q90. Read large file?
pd.read_csv('file.csv', chunksize=1000)
Q91. What is categorical data?
Data with limited unique values.
Q92. Convert to category?
df['col'] = df['col'].astype('category')
Q93. What is pivot?
Reshapes data based on column values.
Q94. Example pivot?
df.pivot(index='A', columns='B', values='C')
Q95. What is melt?
Unpivots DataFrame.
Q96. Example melt?
pd.melt(df)
Q97. What is duplication handling?
Removing duplicate rows using drop_duplicates().
Q98. Check memory usage?
df.memory_usage()
Q99. What is chaining?
Applying multiple operations in one line.
Q100. Example chaining?
df.dropna().sort_values('col')

 

 

 

đŸ“¢ Join Our WhatsApp Channel

đŸ’¼ Get Daily IT Job Updates, Interview Preparation Tips & Instant Alerts directly on WhatsApp.

đŸ‘‰ Join WhatsApp Now

đŸ“¢ Join Our Telegram Channel

đŸ’¼ Get Daily IT Job Updates, Interview Tips & Exclusive Alerts directly on Telegram!

đŸ‘‰ Join Telegram

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 - 2025 itfreesource.com

Enable Notifications OK No thanks