Write the statement to change the value at 5th row, 6th column in a Dataframe df.
Ans:df.iat[4,5] = 23 you can assign any value to the given element.
Write the statement to change the value at 5th row, 6th column in a Dataframe df. Read More »
Ans:df.iat[4,5] = 23 you can assign any value to the given element.
Write the statement to change the value at 5th row, 6th column in a Dataframe df. Read More »
Ans:Syntax to delete a column from a Dataframe is :del <dataframe object>[<column name>]for example:del df[‘first’]
Write statement(s) to delete a column from a Dataframe. Read More »
Ans:We can use df.drop(<row Number>) or df.drop(<row name>) statements to delete a row. for exampledf.drop(4)ordf.drop(‘first’)
Write statement(s) to delete a row from Dataframe Read More »
Ans:(a)del df[<columnname>](b)df.drop(range(3,7))(c)df.isnull().values.any()(d)df.fillna(999, inplace = True)
Ans:to add a new column ‘val’ in dataframe ‘df’ we will write-df[‘val’]=[12,23,45,43,55,12,23,43,11,29]Here we are assigning 10 different values to ‘val’ column as df have 10 rows.
Ans:(a)print(df[[‘Item’,’revenue’]) (b)print(df.loc(3:8)) (c)print(df.Item[5])
A B D 0 15 17 19 1 16 18 20 2 20 21 22 What will be the result of following code segment ?(a) df[‘C’] = np.NaN(b) df[‘C’] = [2,5](c) df[‘C’] = [12, 15, 27] Ans (a) A B D C 0 15 17 19 NaN 1 16 18 20 NaN 2 20 21
Given a dataframe df as shown below: Read More »
S1 S2 0 3 0 12 1 5 2 10 2 6 3 15 4 10 4 20 5 12 6 27 Ans: 0 9 1 NaN 2 4 3 NaN 4 10 5 NaN 6 NaN
Given following Series objects: (b) What will be the result of S1 – S2 ? Read More »
S1 S2 0 3 0 12 1 5 2 10 2 6 3 15 4 10 4 20 5 12 6 27 Ans: 0 15 1 NaN 2 16 3 NaN 4 30 5 NaN 6 NaN
Given following Series objects: (a) What will be the result of S1 + S2 ? Read More »
a) if the series is empty – print(seal.empty)b) indexes of the series – print(seal.index)c) the data type of underlying data – print(seal.dtype)d) if the series stores any NaN values – print(seal.hasnans)
Write commands to print following details of a Series object seal. Read More »