Python Data Processing with Pandas
Total Page:16
File Type:pdf, Size:1020Kb
Python Data Processing with Pandas CSE 5542 Introduc:on to Data Visualizaon Pandas • A very powerful package of Python for manipulang tables • Built on top of numpy, so is efficient • Save you a lot of effort from wri:ng lower python code for manipulang, extrac:ng, and deriving tables related informaon • Easy visualizaon with Matplotlib • Main data structures – Series and DataFrame • First thing first • Series: an indexed 1D array • Explicit index • Access data • Can work as a dic:onary • Access and slice data DataFrame Object • Generalized two dimensional array with flexible row and column indices DataFrame Object • Generalized two dimensional array with flexible row and column indices DataFrame Object • From Pandas Series DataFrame Object • From Pandas Series DataFrame Object • Another example Viewing Data • View the first or last N rows Viewing Data • Display the index, columns, and data Viewing Data • Quick stas:cs (for columns A B C D in this case) Viewing Data • Sor:ng: sort by the index (i.e., reorder columns or rows), not by the data in the table column Viewing Data • Sor:ng: sort by the data values Selecng Data • Selec:ng using a label Selecng Data • Mul:-axis, by label Selecng Data • Mul:-axis, by label Slicing: last included Selecng Data • Select by posi:on Selecng Data • Boolean indexing Selecng Data • Boolean indexing Seng Data • Seng a new column aligned by indexes Seng Data Operaons • Descrip:ve stas:cs – Across axis 0 (rows), i.e., column mean – Across axis 1 (column), i.e., row mean Operaons • Apply • Histogram Merge Tables • Join Merge Tables • Append Grouping File I/O • CSV File I/O • Excel .