1.11 LAB: Data frames

The Cars dataset has three columns giving the quality, machining angle, and machining speed of 18 cars.

Write a program that performs the following tasks:

Load the data Cars.csv into a data frame called cars_df.

Subset the first userNum rows of the data frame into a new data frame.

Find and print the maximum values of each column in the subset.

Ex: If the input is:

5
the output is:

Quality 5
Speed 4
Angle 3
dtype: int64

Respuesta :

fichoh

To work with data frames in python, the pandas library ls very efficient. Therefore, the following lines of code will load, subset and display the maximum value of each column in the subset :

import pandas as pd

#This imports the pandas dataframe and alias it as pd

df_cars = pd.DataFrame('Cars.csv')

Subsetting the firsts UserNum row :

Using the index location method, the first userNum row has a row index of 0.

df_subset = df.iloc[:0, :]

#this selects only the first row and all the columns

#first row of df_cars dataframe has been assigned to another dataframe called the df_subset

df_subset.max()

#the max function returns the maximum value for each column

Note : the cars.csv data wasn't provided, However, this is a run-through of how to get the required output.

Learn more :https://brainly.com/question/16183131?referrer=searchResults