This assignment helps you review the fundamental operations of Pandas DataFrame. Please download the data file automobile_data.csv from Moodle, and develop a Python program that performs the following tasks:
- Create a Pandas DataFrame by loading the file csv.
- Show the shape of the DataFrame.
- Show the first 8 rows and the last 8 rows of your DataFrame.
- Show the data types of every column of your DataFrame.
- There are some rows with missing data. Please drop these rows from the DataFrame.
- Show the shape of the DataFrame again.
- Create a new DataFrame that consists of all the rows of Toyota cars. You can first use groupby() function to generate a GroupBy object, and then use GroupBy.get_group() function to generate the DataFrame object. You can learn from the Grouping example at
https://pandas.pydata.org/pandasdocs/stable/user_guide/cookbook.html ([114], [115], [117], [118]).
- Find the average mileage of each car company. You can make use the GroupBy object created in Step 7.
- Sort all cars by the price column in descending order, and save the sorted table in a new CSV file automobile_data_new.csv. You can use the to_csv() function.
- Show the statistics information (such as mean, std, min, max, and 25/50/75% percentiles) of the final DataFrame.
Reviews
There are no reviews yet.