0% found this document useful (0 votes)
24 views7 pages

IP Practical File

The document contains a series of questions and answers related to Python programming and data manipulation. It discusses syntax errors in Python code, the behavior of lists and Series, and various types of functions in data analysis. Additionally, it explains the differences between creating dataframes in pandas and the use of aggregate functions in SQL.

Uploaded by

vedant ved
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)
24 views7 pages

IP Practical File

The document contains a series of questions and answers related to Python programming and data manipulation. It discusses syntax errors in Python code, the behavior of lists and Series, and various types of functions in data analysis. Additionally, it explains the differences between creating dataframes in pandas and the use of aggregate functions in SQL.

Uploaded by

vedant ved
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
You are on page 1/ 7

The python code written below has syntactical errors.

Rewrite the correct code and


underline the corrections made.

ANS 1

Complete the given Python code to get the required output as: Rajasthan

Ans2

Fill the missing statements to get the given output:

Ans3

Consider two objects L and S. L is a list whereas S is a Series. Both have values 20, 40,90, 110. What will be
the output of the following two statements considering that the above objects have been created already.

print (L+2) #Statement 1

print (S+2) #Statement 2

ANS4
ANS 5

ANS6

Ans7
a- stock=pd.DataFrame()
b- stock [ 'discount']=[15,20,30,25]
c- stock.drop('discount',axis=1)
ANS8
Single Row Functions and Multi-Row Functions.
1. Single Row Functions: Single Row Functions operate on a single
row at a time and return a single result per row. These functions
are used to manipulate or modify data values within a single row
and return the modified value. Single Row Functions can be
further classified into the following categories:
 Numeric Functions: These functions operate on numeric data
types and return numeric values.
 String Functions: These functions operate on string data types
and return string values.
 Date Functions: These functions operate on date and time data
types and return date and time values.
 Conversion Functions: These functions are used to convert data
from one data type to another.
 Miscellaneous Functions: These functions include various other
types of functions that do not fit into the above categories.

2. Multi-Row Functions: Multi-Row Functions, also known as Group


Functions, operate on a group of rows and return a single result
per group. These functions are used to perform calculations on a
set of rows and return a single result for the entire group. Multi-
Row Functions can be further classified into the following
categories:
 Aggregate Functions: These functions are used to perform
calculations on a set of rows and return a single result for the
entire group. Examples include SUM, AVG, COUNT, MAX, and
MIN.
 Analytical Functions: These functions are used to perform
calculations on a set of rows and return a result for each row in
the group. Examples include RANK, DENSE_RANK, and
ROW_NUMBER.

ANS9

Ans10
Ans11
difference between the following two statements, which are creating
two dataframes using the same dataframe, is as follows:
1. Df2=pd.DataFrame(df1): This statement creates a new
dataframe Df2 using the existing dataframe df1. The new
dataframe Df2 is a reference to the existing dataframe df1. This
means that any changes made to Df2 will also affect the original
dataframe df1.
2. Df3=pd.DataFrame(df1, copy=True): This statement creates a
new dataframe Df3 using the existing dataframe df1 and sets
the copy argument to True. The new dataframe Df3 is a copy of the
existing dataframe df1. This means that any changes made
to Df3 will not affect the original dataframe df1.

Ans12

Ans13
Aggregate functions are a type of function in databases and
programming languages that perform a calculation on a set of values
and return a single value as a result. These functions are used to
summarize data, making it easier to analyze and understand trends or
patterns. They are particularly useful in SQL (Structured Query
Language) for database management systems, but they are also found
in other programming languages and data analysis tools.
some common aggregate functions and their descriptions:
1. COUNT: Counts the number of rows that match a specified criterion. It
can be used to count all rows or only those that are not null for a
specified column.
2. SUM: Adds together all the values in a particular column. It is typically
used with numeric data types.
3. AVG: Calculates the average of the values in a column. It ignores NULL
values and only works with numeric data types.
4. MIN: Finds the smallest value in a column. It can be used with numeric,
string, and date/time data types.
5. MAX: Finds the largest value in a column. It can also be used with
numeric, string, and date/time data types.
Ans14
The GROUP BY clause in SQL is used to group rows that have the same
values in one or more columns, and it is often used in conjunction with
aggregate functions to perform calculations for each group. The GROUP
BY clause follows the FROM clause and comes before the ORDER
BY clause if it's used.

Ans15

Ans16

Ans17
Ans18
i.

ii.

Ans19

Ans20

You might also like