198k views
0 votes
The file named 'Electric_Vehicle_Population_Data.csv' contains the database of electric vehicles registered and operated in different cities and states (primarily Washington State) of the United States. It also contains the vehicle details like make, model, model year, vehicle type, electric range, base retail price and fields that are mostly self explanatory. (POINTS: 54 - each task in this exercise carries 9 points) Task-1: Read the Electric_Vehicle_Population_Data.csv file and store in a variable name ev_pop. After reading, display the first 10 rows of the dataframe ev_pop as the output.

User Atif Aziz
by
7.9k points

1 Answer

5 votes

Final answer:

To read and display the first 10 rows of the 'Electric_Vehicle_Population_Data.csv' file, a DataFrame can be created using pandas in Python and the .head() method can be used to print the first 10 rows.

Step-by-step explanation:

The student's task involves using data manipulation and reading capabilities in a programming language like Python. To accomplish Task-1, one can use libraries like pandas to read the 'Electric_Vehicle_Population_Data.csv' into a DataFrame. Then, the first 10 rows of the DataFrame can be displayed using the .head() method. The code snippet for this task in Python would be as follows:

import pandas as pd
ev_pop = pd.read_csv('Electric_Vehicle_Population_Data.csv')
print(ev_pop.head(10))

This will read the CSV file into the variable ev_pop and print the first 10 rows of the DataFrame to the output. It is essential to ensure that the CSV file is in the correct directory or to provide the absolute path to the file in the pd.read_csv() function.

User Killebytes
by
8.1k points