Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Create a New Dataframe - Intro to Data Science

Get Embed Code
2 Languages

Showing Revision 5 created 05/24/2016 by Udacity Robot.

  1. Panda also allows us to operate on your data frame in
  2. a vectorized item by item way. What does it mean to
  3. operate on a data frame in a vectorized way? Well first
  4. let's create a new data frame. Note that first I want
  5. to create a dictionary where the keys are going to be
  6. my column names and the values are series corresponding to their
  7. values and then the indexes for the rows where these values
  8. should appear. In order to make a data frame, I can simply
  9. say df equals data frame of this dictionary
  10. d. Let's see what this data frame looks
  11. like. We can call dataframe.apply and pass in
  12. some arbitrary function. In this case, numpy.mean to perform
  13. that function on every single column in the
  14. data frame. So when we df.apply numpy.mean, what
  15. we get back is the mean of each column in our data frame df. There are also
  16. some operations that simply cannot be vectorized in
  17. this way, that is, take a numpy.mean as their
  18. input, and then return an array or a
  19. value. So we can also call map on particular
  20. columns or apply map on entire data frames.
  21. These methods also accept functions, but functions that take
  22. in a single value and return a single
  23. value. For example, if I were to type
  24. lambda x, x greater than or equal to 1, what I get back here is whether or not
  25. every single value in the column 1 is greater than or equal to 1. Now say that I
  26. were to call df.applymap lambda x, x greater than
  27. or equal to 1, what this function returns is
  28. whether or not every single value in the data
  29. frame df is greater than or equal to 1.
  30. This is just the tip of the iceberg
  31. when it comes to Panda's functionality. If you're interested
  32. to read more about what the library can do,
  33. you should check out the full documentation at the
  34. URL contained in the instructor notes. Now, we
  35. know some of the very basics when it comes
  36. to handling the data, but how do we acquire
  37. the data that we wish to handle and analyze?