Question

For Jupyter Notebook we have opened up a file using pandas but I am confused on...

For Jupyter Notebook we have opened up a file using pandas but I am confused on this question and how to do it.

  1. Create a new dataframe that only contains the data where fuel is “regular” AND MPG is over 21. Call it Auto_sub. Label each section using markup to state what you are doing and what you see
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#CODE

import pandas as pd
import numpy as np

df=pd.read_csv('database.csv')
df.head()

#IF your MPG contains string type data remove it from dataframe
df=df[df['MPG'].apply(lambda x: True if isinstance(x,int) else False)]
Auto_sub=df[(df['fuel'].str.lower()=='regular') & (df['MPG'] > 21)]#We are using lower to make non-case sensitive

Auto_sub.shape#To get the shape of Auto_sub

Auto_sub.head()#To view the data

Add a comment
Know the answer?
Add Answer to:
For Jupyter Notebook we have opened up a file using pandas but I am confused on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table()...

    (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table() function. Check the first five rows. (b) Create a new dataframe called tips by randomly sampling 6 records from the dataframe tips_df. Refer to the sample() function documentation. (c) Add a new column to tips called idx as a list ['one', 'two', 'three', 'four', 'five', 'six'] and then later assign it as the index of tips dataframe. Display the dataframe. (d) Create a new...

  • Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data...

    Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data Files We provide three comma-separated-value file, scores.csv , college_scorecard.csv, and mpg.csv. The first file is list of a few students and their exam grades. The second file includes data from 1996 through 2016 for all undergraduate degree-granting institutions of higher education. The data about the institution will help the students to make decision about the institution for their higher education such as student completion,...

  • 23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4...

    23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...

  • Use the link in the Jupyter Notebook activity to access your Python script. Once you have...

    Use the link in the Jupyter Notebook activity to access your Python script. Once you have made your calculations, complete this discussion. The script will output answers to the questions given below. You must attach your Python script output as an HTML file and respond to the questions below. In this discussion, you will apply the statistical concepts and techniques covered in this week's reading about hypothesis testing for the difference between two population proportions. In the previous week’s discussion,...

  • 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this...

    23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same as what you had for your chapter 13 labs). The following is an example of...

  • This is a java file and I am very confused on how to do this project!...

    This is a java file and I am very confused on how to do this project! please help!! Specifications Overview: You will write a program this week that is composed of three classes: the first class defines Ellipsoid objects, the second class defines EllipsoidList objects, and the third, Ellipsoid ListApp, reads in a file name entered by the user then reads the list name and Ellipsoid data from the file, creates Ellipsoid objects and stores them in an ArrayList of...

  • I am confused on how to read valid lines from the input file. I am also...

    I am confused on how to read valid lines from the input file. I am also confused on how to count the averages from these valid input lines to keep running the total from these valid lines. If you could show an example of an input and output file that would be amazing as well. Purpose        Learn how to use Java input/output. Due Date       Per the Course at a Glance. Can be resubmitted. Submissions           In this order: printed copy of...

  • I am very confused about how to work this problem. I don't have a lot of...

    I am very confused about how to work this problem. I don't have a lot of experience using formulas in Excel. This bond is a 20-year, 8% semiannual coupon bond with a par value of $1,000 may be called in 5 years at a call price of $1,040. The bond sells for $1,100. (Assume that the bond has been issued.) She needs you to complete the partial model for her. She needs the following to be answered. What is the...

  • Hello! I am to create a .js file that allows the paragraph on the bottom of...

    Hello! I am to create a .js file that allows the paragraph on the bottom of the page to update with what the user enters. I need to modify the given HTML to recognize the javascript file that I am to make from scratch. The HTML file and other details are below: Use the given HTML to add functionality to an interactive form that generates an invitation to volunteers for an event. The file will have the following invitation message...

  • need help setting up, I am confused as to where all the forces go, and what...

    need help setting up, I am confused as to where all the forces go, and what the force us indicated by the arrow is since it is from a birds eye view, unlike the examples we have. thank you! What is this force? Answer here Using the diagram above, express Fly and F. in terms of Fran and : FILE F1 = Note that when the fan points straight back, we have: Fran = m a straight Apply Newton's 2nd...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT