oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Exploring data using pandas #326

Open oldoc63 opened 2 years ago

oldoc63 commented 2 years ago

pandas library is designed for working with data. Start by importing the library and using the read csv() function to read de CSV data into a DataFrame object:

oldoc63 commented 2 years ago

By default, the first row of the CSV file is read in as the header row. We can use the .head() method to preview the first few rows of the DataFrame.

Sometimes columns have ambiguous or confusing names (like Census codes). We may also want to rename those columns. We can use the .columns attribute to rename the columns headings if needed:

oldoc63 commented 2 years ago

Instructions

  1. Start by importing the pandas library
  2. Create a variable called commute_df. Set your variable to be a pandas DataFrame from the commute_data.csv file.
  3. Preview the first few rows of commute_df using the .head() method and printout the output.
  4. Notice how the column headings for commute_df show the codes the Census uses. That's not very intuitive! Rename the headings to more descriptive names, then print the first few rows of the DataFrame again to see the changes.