RepoForPython/PfDA.md at master · NickChilling/RepoForPython · GitHub
Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Latest commit

 

History

History
64 lines (34 loc) · 1.2 KB

File metadata and controls

64 lines (34 loc) · 1.2 KB

Python for Data Analysis

[TOC]

Some features of ipython

Tab completion

?

anything plus a ? in ipython , will give you the annotation of that .

%run

run .py file in ipython, just like run it in the power shell

use %run -i to give a script access to the defined namespace in ipython

%load imports a script into a code cell

1532005959533

%matplotlib

In the ipython shell, running %matplotlib sets up the integration so you can create multiple plot windows without interfering with the console session

Ternary expression

value = true-expr if condition else false-expr

Numpy

Basics

all the elements must be the same type

>>> data.shape # dimension of data
(2,3)
>>> data.dtype # type of data
dtype('float64')

like dictionaries closed by {} ,lists closed by [], arrays is closed by ([])

np.zeros((3,6)) # pass a tuple into it to output a 3*6 matrix 

1532009920870

Datatypes

arr1 = np.array([1,2,3],dtype=np.float64) # initialize

arr2 = arr1.astype(np.int64) # transform