3.PYTHON-Pandas.pdf - Licensed for personal use only for...

This preview shows page 1 - 10 out of 39 pages.

Python : Pandas Dataframes IO Data cleanup Datasets Dplyr Graphs Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 1

Subscribe to view the full document.

Lesson Objectives u Learn about Python Pandas u Learn about what Pandas can do for us. Copyright © 2017 Elephant Scale. All rights reserved. 2 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 2
Series è Series IO Data cleanup Datasets Dplyr Graphs Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 3

Subscribe to view the full document.

Series u Pandas has a Series type u Think of a single column in a database table u Must be of same type, though can also be NA (np.nan) u Defaults to float64 (notice that it is converted!) Copyright © 2017 Elephant Scale. All rights reserved. 4 s = pd.Series([1,3,5,np.nan, 6, 8]) 0 1.0 1 3.0 2 5.0 3 NaN 4 6.0 5 8.0 dtype: float64 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 4
Why a new type? Copyright © 2017 Elephant Scale. All rights reserved. 5 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 5

Subscribe to view the full document.

DataFrame è Dataframes IO Data cleanup Datasets Dplyr Graphs Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 6
Data Frame u Data frames hold ‘tabular’ data. u Think ‘Excel spreadsheet’ or ‘database table.’ – Rows & columns u Each column can be a different type. u Each row must have same length. Copyright © 2017 Elephant Scale. All rights reserved. 7 X Y Z 1 2 3 4 5 6 df = pd.DataFrame( {X' : [‘1', ‘4'], ‘Y’: [2, 5], ‘Z’: [3,6]}) Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 7

Subscribe to view the full document.

Creating A Data Frame >>> cities = pd.DataFrame ({ ‘city’ : ['San Francisco', 'Seattle', 'Los Angeles’], ‘pop’ : [10, 15, 20], ‘rain’ = [2, 10,1]}) >>> cities city pop rain 1 San Francisco 10 2 2 Seattle 15 10 3 Los Angeles 20 1 Copyright © 2017 Elephant Scale. All rights reserved. 8 City Pop rain San Francisco 10 2 Seattle 15 10 Los Angeles 20 1 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20 Licensed for personal use only for Sriram Anne <[email protected]> from Python @ Macy's 2018-02-20 @ 2018-02-20
Image of page 8
Data Frame: Appending a New Row >>> cities = pd.DataFrame ({
Image of page 9

Subscribe to view the full document.

Image of page 10
  • Spring '17
  • azmat fatma
  • All rights reserved, Sriram Anne

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern