0% found this document useful (0 votes)
2 views2 pages

Pandas Trick Ques

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Pandas Trick Ques

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DataFrame and Series Basics:

1. How do you create a DataFrame from a dictionary?

2. What is the difference between iloc[] and loc[]? When would you use each?

3. How do you select multiple columns from a DataFrame?

4. How do you filter rows based on a condition in a DataFrame?

5. What is the difference between DataFrame.at[] and DataFrame.iat[]?

6. How can you get the number of rows and columns in a DataFrame?

7. What does the axis parameter do in functions like drop() or sum()?

8. How do you select rows where column A is greater than column B?

9. How can you find the unique values in a column of a DataFrame?

10. How do you reset the index of a DataFrame?

Handling Missing Data:

11. How do you check for missing values in a DataFrame?

12. How can you fill missing values with the mean of a column?

13. What is the difference between dropna() and fillna()?

14. How do you fill missing values forward (propagate the last valid value) in a DataFrame?

15. How do you drop rows that contain missing values in specific columns?

16. How do you fill missing values using different methods for different columns?

17. How do you count the number of missing values in each column?

18. What is the difference between interpolate() and fillna()?

19. How can you fill missing values with values from another column?

20. How do you drop columns that contain only missing values?

Data Manipulation and Transformation:

21. How do you apply a function to every element of a DataFrame column?

22. What is the difference between apply() and applymap()?

23. How can you use lambda functions to create a new column based on existing columns?

24. How do you concatenate two DataFrames vertically and horizontally?

25. What is the difference between merge() and join()?

26. How do you sort a DataFrame by multiple columns?

27. How do you change the data type of a DataFrame column?

28. How do you rename columns in a DataFrame?

29. How do you drop duplicate rows in a DataFrame?

30. How do you map values of a Series to another set of values using map()?

Grouping and Aggregation:

31. How do you group data by a column and calculate the mean for each group?

32. What is the difference between agg() and apply() when using groupby()?

33. How do you group by multiple columns and calculate different aggregates for each group?

34. How can you get the first row of each group in a groupby() operation?

35. How do you perform a custom aggregation on a groupby() object using a lambda function?
36. What is transform() used for in the context of groupby()?

37. How do you use cumsum() to calculate a cumulative sum within each group?

38. How can you pivot a DataFrame using pivot_table()?

39. What is the difference between pivot() and melt()?

40. How do you unstack a multi-index DataFrame?

Tricky Indexing and Selection:

41. What happens if you try to access a column that doesn’t exist using df['column_name']?

42. How do you slice a DataFrame using a range of index values?

43. How do you select all rows where a column value is in a list of values?

44. How do you access a DataFrame cell by row and column names?

45. How can you find the index of the maximum value in a column?

46. How do you select all rows where a column contains a specific substring?

47. How do you select a subset of columns that match a specific pattern (e.g., columns starting with 'A')?

48. What is the difference between df['A'] and df[['A']] when selecting columns?

49. How do you convert an index into a column in a DataFrame?

50. How can you use query() to filter rows based on complex conditions?

Data Cleaning and Preprocessing:

51. How do you remove trailing and leading spaces from string columns?

52. How can you replace all occurrences of a string in a column with another string?

53. How do you convert a date column into a datetime object?

54. How do you extract the year, month, and day from a datetime column?

55. How do you check if a column contains only numeric values?

56. How can you split a string column into multiple columns?

57. How do you convert a datetime column into the index of a DataFrame?

58. How do you standardize (normalize) values in a DataFrame column?

59. How do you drop columns that contain a specific value?

60. How do you remove non-numeric characters from a column?

Advanced Operations and Tricks:

61. How do you calculate the correlation between two columns in a DataFrame?

62. How do you check if a DataFrame is empty?

63. How do you rank values within a column?

64. How can you add a column with a sequence of numbers to a DataFrame?

65. What is the fastest way to get the top N rows based on a column value?

66. How do you count the frequency of unique values in a column?

67. How can you efficiently iterate over rows in a DataFrame?

68. How do you merge two DataFrames with different column names?

69. What is the difference between stack() and unstack() in pandas?

70. How do you find and replace outliers in a DataFrame?

You might also like