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
You are on page 1/ 3
DAV Public School, Ballabhgarh
Python Pandas-I Theory Notes, Class XII
Subject : Informatics Practices 1. What are Python Libraries Ans. Python libraries contain a collection of built-in modules that allow us to perform many actions without writing detailed programs for it. Each library in Python contains a large number of modules that one can import and use. Example of Python Library : Pandas, Metplotlib, Numpy etc. 2. What is PANDAS? Ans PANDAS (PANel DAta) is a high-level data manipulation tool used for analysing data. It is very easy to import and export data using the Pandas library which has a very rich set of functions. It gives us a single, convenient place to do most of our data analysis and visualisation work. Pandas have three important data structures, namely - Series, DataFrame, and Panel to make the process of analyzing data organized, effective and efficient. 3. Who developed Pandas? Ans. Wes Mckinney 4. Why do we use Pandas library? or What are the Features of Pandas library? Ans. It supports Data Visualization Excellently. It handles large data efficiently It can read data in many format It makes data customizable and flexible It handles missing and duplicate data efficiently. Less writing and more work done 5. What is Data Structure in Pandas? Ans. A data structure is a collection of data values and operations that can be applied to that data. It enables efficient storage, retrieval and modification to the data. For example, Series and DataFrame in Pandas, ndarray in NumPy Series . 6. Which Command is used to import pandas library? Ans import pandas as pd 7. What is Series in Pandas? Ans. It is 1D data structure It is size immutable It is value mutable It stores homogeneous data It supports explicit indexing 8. Which function is used to create Series? Write its full syntax. Ans. Series Function of pandas library is used to create Series. Syntax: Pandas.Series(data,index,dtype,copy) 9. What is NaN in Pandas? Ans. NaN represents missing values in Pandas. Its full form is ‘Not a Number’. 10. Write commands to print the following details of a series object (a) empty series (b) indexes of the series (c) data type of the data elements of the series (d) To display whether the series has NaN values Ans. a. Using Series property empty , we can check whether a series is empty or not. Command: print(ser.empty) b. To print index of a series, index property will be used: Command: print(ser.index) c. To print datatype of a series, dtype property is used: Command: print(ser.dtype) d. To display whether a series has NaN value, hasnans property is used: Command: print(ser.hasnans) 11. What is dataframe? Ans It is 2D (Two Dimensional) data structure. Used to manage large and complex data in tabular format It contains both rows and columns and hence have both row and column indexes. Most commonly used data structure similar to spreadsheet. 12. Why do we use dataframe OR What are the Features of dataframe It can store any type (heterogeneous) of data It is size mutable It is value mutable Both indexes can be labelled Indexes may constitute any type of value such as number, string, character, Boolean value. Index of dataframe can also be referred as axis'. axis = 0 refers to row index and axis = 1 refers to column. 13. Which function is used to create dataframe. Write its syntax. Ans. DataFrame() function of pandas is used to create dataframe. Syntax: Pandas.DataFrame(data,index,columns,dtype,copy) 14. Write and Explain Properties (Attrubutes) of a Series Object. Ans. Series.index : Returns index of the Series Series.values: Returns ndarray of values of Series Series.dtype: Returns datatype of Series data. Series.shape: Returns tuple of the shape of series data. Series.ndim: Returns the number of dimensions ie 1 in Series always Series.size: Returns number of elements of series Series.hasnans: Rerturns true if there is any NaN (missing value) Series.empty: Returns true if Series object is empty 15. Write and Explain Methods of a Series object. A ns. Series.head(n): Returns the first n members of the series. If the value for n is not passed, then by default n takes 5 and the first five members are displayed. Series.tail(n) : Returns the last n members of the series. If the value for n is not passed, then by default n takes 5 and the last five members are displayed. 16. What is the difference between Series and DataFrame? Property Series Dataframe Dimensions 1-Dimesnional 2-Dimensional Type of data Homogeneous Heterogeneous Mutability Value Mutable but Value and Size Mutabe Size Immutable 17. Write all the attributes (properties) of Dataframe Object. Ans dataframe.index: Returns the row lables dataframe.columns: Returns column index dataframe.axes: it returns both row and column indexes dataframe.values: Rerturn values in the form of 2D Numpy array dataframe .dtype: returns datatype of each column of dataframe dataframe.size: returns the total number of elements of dataframe. dataframe.shape: it returns the tuple of number of rows and number of columns. dataframe.ndim: Returns the no. Of dimensions dataframe.empty: Returns true if dataframe object is empty dataframe.T: transpose the datafrme ie rows become columns and vice versa 18. Write functions (methods) of Dataframe. Ans Head(), Tail() and count() What advantages does dataframe offer over series datastructure? If you have similar data stored in a multiple series and a single dataframe, which one would you prefer and why? How can we fill in Missing values in DataFrame?