TGTGInsighttelegram intelligenceLIVE / telegram public index
← Data Analytics
Data Analytics avatar

TGINSIGHT POST

Post #2237

@sqlspecialist

Data Analytics

Views5,310Post view count
PostedAug 2008/20/2025, 02:18 PM
Post content

Post content

Python Interview Questions with Answers Part-3:☑️ 21. How do you perform basic statistical operations in Python? Use libraries like NumPy (np.mean(), np.median(), np.std()) and Pandas (df.describe()) for statistics like mean, median, variance, etc. 22. What libraries do you use for data visualization? Common ones are Matplotlib, Seaborn, Plotly, and sometimes Bokeh for interactive plots. 23. How do you create plots using Matplotlib or Seaborn? In Matplotlib: import matplotlib.pyplot as plt plt.plot(x, y) plt.show() In Seaborn: import seaborn as sns sns.barplot(x='col1', y='col2', data=df) 24. What is the difference between .apply() and .map() in Pandas? ⦁ .apply() can work on entire Series or DataFrames and accepts functions. ⦁ .map() maps values in a Series based on a dict, Series, or function. 25. How do you export Pandas DataFrames to CSV or Excel files? Use df.to_csv('file.csv') or df.to_excel('file.xlsx'). 26. What is the difference between Python’s range() and xrange()? In Python 2, range() returns a list, xrange() returns an iterator for better memory usage. In Python 3, range() behaves like xrange(). 27. How can you profile and optimize Python code? Use modules like cProfile, timeit, or line profilers to find bottlenecks, then optimize with better algorithms or vectorization. 28. What are Python decorators and give a simple example? Functions that modify other functions without changing their code. Example: def decorator(func): def wrapper(): print("Before") func() print("After") return wrapper @decorator def say_hello(): print("Hello") 29. How do you handle dates and times in Python? Use datetime module and libraries like pandas.to_datetime() or dateutil to parse, manipulate, and format dates. 30. Explain list slicing in Python. Get sublists using syntax list[start:stop:step]. Example: lst[1:5:2] picks items from index 1 to 4 skipping every other. React ♥️ for Part 4