0% found this document useful (0 votes)
30 views6 pages

Viva Questions Python

Pandas is a Python library designed for data analysis and handling, particularly effective for structured data manipulation. It features two primary data structures: Series and DataFrame, which allow users to work with one-dimensional and two-dimensional labeled data, respectively. Pandas supports various file formats, handles missing data, and provides numerous functions for data operations, making it a powerful tool for data science.

Uploaded by

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

Viva Questions Python

Pandas is a Python library designed for data analysis and handling, particularly effective for structured data manipulation. It features two primary data structures: Series and DataFrame, which allow users to work with one-dimensional and two-dimensional labeled data, respectively. Pandas supports various file formats, handles missing data, and provides numerous functions for data operations, making it a powerful tool for data science.

Uploaded by

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

1. What is Pandas?

A Python library used for data analysis and data handling.

2. Why is Pandas used in data science?


For fast, easy manipulation and analysis of structured data.

3. Which package is imported to use Pandas?


import pandas as pd

4. Name two main data structures in Pandas.


Series and DataFrame.

5. What type of data does Pandas handle best?


Tabular or structured data.

6. Is Pandas built on NumPy?


Yes.

7. What is tabular data?


Data arranged in rows and columns.

8. Can Pandas handle missing data?


Yes.

9. What file formats can Pandas read?


CSV, Excel, JSON, SQL, etc.

10. What does NaN stand for?


Not a Number (missing value).

11. What is a Series?


A one-dimensional labeled array.

12. How is Series different from list?


Series has an index; list does not.

13. How do you create a Series from a list?


[Link]([1,2,3])

14. What is the default index in Series?


0, 1, 2, …

15. Can Series store different data types?


Yes.

16. How do you create a Series with custom index?


[Link](data, index=labels)

17. How do you access a value using index label?


s['a']

18. How do you access a value using position?


s[0]

19. What attribute returns data type of Series?


.dtype
20. What does .size return?
Number of elements.

21. What does .values return?


Underlying NumPy array.

22. What does head() do?


Shows first 5 elements.

23. What does tail() do?


Shows last 5 elements.

24. How do you check null values in Series?


isnull() or isna()

25. How do you remove null values from Series?


dropna()

26. Can Series be created from a dictionary?


Yes.

27. In Series created from dictionary, keys become?


Index.

28. What happens when you add two Series?


Values are added based on index.

29. What if indexes don’t match during operation?


Result will be NaN.

30. How do you convert Series to list?


tolist()

31. What is a DataFrame?


A 2-D labeled data structure.

32. How many dimensions does DataFrame have?


Two.

33. What are columns in DataFrame?


Series objects.

34. How do you create a DataFrame from dictionary?


[Link](dict)

35. How do you create DataFrame from list of lists?


[Link](data)

36. What is the default index in DataFrame?


0, 1, 2, …

37. Can columns have different data types?


Yes.

38. How do you view first 5 rows?


head()
39. How do you view last 5 rows?
tail()

40. How do you check number of rows and columns?


.shape

41. How do you check column names?


.columns

42. How do you check data types of columns?


.dtypes

43. What does info() show?


Structure and data types.

44. What does describe() show?


Statistical summary.

45. How do you select a single column?


df['col']

46. What is returned when a column is selected?


A Series.

47. How do you select multiple columns?


df[['c1','c2']]

48. How do you select a row by label?


loc[]

49. How do you select a row by position?


iloc[]

50. What is the axis value for rows?


Axis = 0

51. What is the axis value for columns?


Axis = 1

52. How do you add a new column?


df['new'] = values

53. How do you rename columns?


rename()

54. How do you delete a column?


drop()

55. Does drop() delete permanently?


Only if inplace=True

56. How do you find missing values?


isnull()

56. How do you remove rows with missing values?


dropna()
57. How do you fill missing values?
fillna()

58. How do you replace values in DataFrame?


replace()

59. How do you sort by column values?


sort_values()

60. How do you sort by index?


sort_index()

61. How do you filter rows?


Using conditions.

62. Example of filtering rows?


df[df['Marks']>50]

63. What does groupby() do?


Groups data for aggregation.

64. Name two aggregation functions.


sum(), mean()

65. What does apply() do?


Applies function to rows/columns.

66. Can arithmetic operations be done on DataFrames?


Yes.

67. What happens if shapes mismatch?


Result may contain NaN.

68. How do you check duplicate rows?


duplicated()

69. How do you remove duplicate rows?


drop_duplicates()

70. How do you count non-null values?


count()

71. How do you count unique values?


nunique()

72. How do you get unique values?


unique()

73. How do you reset index?


reset_index()

74. How do you set a column as index?


set_index()

75. What is slicing in DataFrame?


Selecting subset of rows/columns.
76. Is DataFrame mutable?
Yes.

77. What is vectorization?


Performing operations without loops.

78. Why is Pandas faster than loops?


Uses vectorized operations.

79. What is broadcasting?


Automatic expansion of values.

E. File Handling with Pandas (81–100)

81. How do you read a CSV file?


pd.read_csv()

82. How do you read Excel file?


pd.read_excel()

83. How do you write DataFrame to CSV?


to_csv()

84. How do you write DataFrame to Excel?


to_excel()

85. What parameter removes index while saving CSV?


index=False

86. What is delimiter in CSV?


Character separating values.

87. Default delimiter in CSV?


Comma (,)

88. What does read_csv() return?


A DataFrame.

89. Can Pandas connect to SQL?


Yes.

90. What is real-life use of DataFrame?


Student records, sales data, analysis.

91. What is data cleaning?


Removing errors and missing values.

92. Why is DataFrame preferred over Excel?


Automation and large data handling.

93. Can DataFrame handle large datasets?


Yes.
94. What is index in DataFrame?
Row labels.

95. Are indexes unique by default?


Yes.

96. Can index be changed?


Yes.

97. Is Pandas open source?


Yes.

98. What is “localhost” in Python–MySQL Database Connectivity?

Localhost refers to the same computer (local machine) on which your Python
program and MySQL database server are running.

99. What is a Cursor in Python–MySQL?

A cursor is an object used to execute SQL queries and retrieve results from a database
in Python.

You might also like