Answer to Question #294100 in Python for shibasis pattnayak

Question #294100

1. Consider the following data to answer the question below


What is the command to convert the above dictionary into a dataframe named ‘df_state’?

2. List 3 commands to display the columns of the above dataframe df_state.

 

3. Correlation between two variables X&Y is 0.85. Now, after adding the value 2 to all the values of X, the correlation co-efficient will be______

4. A) Read the given dataset “Tips.csv” as a dataframe “Data”. Give 3 commands to extract the columns in the following sequence - Time, TotalBill, Tips?

 

B)     Read the given excel sheet ‘Tips1.xlsx’ as a dataframe ‘Data1’. What command should be given to merge the two data frames ‘Data’ and ‘Data1’ by columns?

 

C)     Copy the 'Data1' dataframe as 'Data2' (Data2 = Data1.copy()) and identify the command to find the total tips received across Day’s from the dataframe ‘Data2’?

 


1
Expert's answer
2022-02-05T02:03:44-0500

(1)

the pd. DataFrame. from_dict() class-method.


(2)

1. Using pandas. dataframe. columns to print column names in Python.

2.Using pandas. dataframe. columns.

3.Python sorted() method to get the column names. Python sorted() method can be used to get the list of column names of a dataframe in an ascending order of columns.

(3) a correlation coefficient of 0.85 shows the same strength as a correlation coefficient of -0.85.


(4)

(a)df1=pd.DataFrame(Data, columns= ['Time', 'TotalBill', 'Tips'])

df1-Data[ ['Time', 'TotalBill', 'Tips']]

df1-Data.loc[:, ['Time', 'TotalBill', 'Tips']]

(b) Data2 = pd.merge(Data, Data1, how="left')

(c)Data3.groupby('Day')[['Tips']].aggregate(sum)


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS