Informatics Practices
Assertion (A): We can add a new column in an existing dataframe using .at or .loc methods.
Reasoning (R): When we reassign new values to an existing column in a dataframe, the previous values are overwritten.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Python Data Handling
1 Like
Answer
Both A and R are true but R is not the correct explanation of A.
Explanation
We can add a new column in an existing dataframe using at or loc methods. When we reassign new values to an existing column in a dataframe, the previous values are overwritten.
Answered By
3 Likes
Related Questions
Assertion (A): The shape attribute returns the number of rows and number of columns available in dataframe.
Reasoning (R): The shape attribute returns the values in the form of list.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): After running the following code:
df = pd.DataFrame([11,46], index = ['True', 'False']) print(df[True])A key error will be produced.
Reasoning (R): Dataframe does not support Boolean Indexing.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): When a dataframe is created using dictionary, the keys will be the columns and corresponding values will be the rows of the dataframe.
Reasoning (R): NaN values are automatically filled for values of non-matching keys while creating a dataframe using dictionary.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Inayra is writing a program using Pandas library for creating a dataframe from two dictionaries. Given below is the snippet she has developed. Help her to complete it by selecting the correct option given as under:
import ............... as pd # Statement 1 dict = {'x': [10,25], 'y' : [32,93] } dict 1 = {'x',: [14,56], 'y': [36,72] } df = pd.DataFrame (dict) df1 = pd. ............... (dict) # Statement 2 df2 = pd. ............... ([df, df1]) # Statement 31. Choose the correct option from the following for Statement 1.
(a) pd
(b) data
(c) df
(d) pandas2. Which of the following option should be taken for Statement 2?
(a) Series
(b) Dataframe
(c) DataFrame
(d) Dictionary3. Select the correct method from the following for Statement 3.
(a) concat()
(b) shape()
(c) index()
(d) append()