Professional Documents
Culture Documents
Cheat Sheet Template
Cheat Sheet Template
Cheat Sheet Template
>>> x%2
>>> my_list + my_list >>>
1
Division of a variable ['my', 'list', 'is', 'nice', 'my', 'list', 'is', 'nice']
>>> x/float(2)
my_list * 2
2.5
['my', 'list', 'is', 'nice', 'my', 'list', 'is', 'nice']
Types and Type Conversion >>> my_list2 > 4
True
str() ' 5', '3.45', 'True' Variables to strings
List Methods
int() 5, 3, 1 Variables to integers
>>> my_list.index(a) Get the index of an item Count
>>> my_list.count(a) an item
float() 5.0, 1.0 Variables to floats >>> my_list.append('!') Append an item at a time
>>> my_list.remove('!') Remove an item
Variables to booleans >>> del(my_list[0:1]) Remove an item
bool() True, True, True
>>> my_list.reverse() Reverse the list
>>> my_list.extend('!') Append an item
Help >>> my_list.pop(-1) Remove an item
>>> my_list.insert(0,'!') Insert an item
>>> help(str) >>> my_list.sort() Sort the list
Strings
>>> my_string = 'thisStringIsAwesome'
>>> my_string 'thisStringIsAwesome'
String Operations Index starts at 0
>>> my_string[3]
String Operations >>> my_string[4:9]
>>> my_string * 2 String Methods
'thisStringIsAwesomethisStringIsAwesome'
>>> my_string + 'Innit' >>> my_string.upper() String to uppercase
'thisStringIsAwesomeInnit' >>> my_string.lower() String to lowercase
>>> 'm' in my_string >>> my_string.count('w') Count String elements
True >>> my_string.replace('e', 'i') Replace String elements
>>> my_string.strip() Strip whitespaces
Libraries
Install Python
Import libraries
>>> import numpy
>>> import numpy as np Data analysis Machine learning
Selective import
>>> from math import pi
Scientific computing 2D plotting Leading open data science
Free IDE that is
Create and share
@aadhi06 my profile
@cloudnloud @cloudnloud info@cloudnloud.com @cloudnloud cloudnloud
Numpy Arrays
>>> my_list = [1, 2, 3, 4]
>>> my_array = np.array(my_list)
Community
>>> my_2darray = np.array([[1,2,3],[4,5,6]])
Selecting Numpy Array Elements Index starts at 0
Python For Data Science CheatSheet
Subset
>>> my_array[1] Select item at index
Pandas Basics
2 1
Slice
Select items at index 0 and
my_2darray[rows,
Also see NumPy Arrays >>> data = {'Country': ['Belgium', 'India', 'Brazil'], 'Capital':
>>> s['b'] Get one element ['Brussels', 'New Delhi', 'Brasília'], 'Population': [11190846,
-5 1303171035, 207847528]}
>>> df[1:] Get subset of a DataFrame
>>> df = pd.DataFrame(data, columns=['Country', 'Capital',
Country Capital Population 1 India New Delhi 1303171035 2 Brazil Brasília
207847528
'Population'])
Selecting, Boolean Indexing & Setting
Getting
By Position
>>> df.iloc[[0],[0]]
'Belgium'
Select a single value by row & column
Dropping
>>> df.iat([0],[0])
'Belgium' >>> s.drop(['a', 'c']) Drop values from rows (axis=0)
By Label >>> df.drop('Country', axis=1) Drop values from columns(axis=1)
>>> df.loc[[0], ['Country']]
'Belgium'
Select single value by row & column labels Sort & Rank
>>> df.at([0], ['Country']) >>> df.sort_index() Sort by labels along an axis
'Belgium' >>> df.sort_values(by='Country') Sort by the values along an
>>> df.rank() axis Assign ranks to entries
By Label/Position
Select single row of subset of rows
>>> df.ix[2]
Country Brazil
Retrieving Series/DataFrame Information
Capital Brasília
Basic Information
Population 207847528 Select a single column of subset of columns >>> df.shape (rows,columns)
>>> df.ix[:,'Capital']
>>> df.index Describe index
0 Brussels >>> df.columns Describe DataFrame
1 New Delhi >>> df.info() columns Info on DataFrame
2 Brasília Select rows and columns Number of non-NA values
>>> df.count()
>>> df.ix[1,'Capital'] Series s where value is not >1
'New Delhi' where value is <-1 or >2 Summary
>>> df.sum() Sum of values
Boolean Indexing
@aadhi06 my profile
@cloudnloud @cloudnloud info@cloudnloud.com @cloudnloud cloudnloud
Community
Who we Are ?
Cloudnloud Tech Community was started by Vijayabalan a cancer survivor in 2011 with the notion to save
the children diagnosed with cancer by creating a sustainable source of funds for their treatment. The
community helps Indian IT aspirants to dream bigger than the monotonous job search system and instead
achieve great heights of life by building a name for themselves. Over the years, the community has emerged
globally and the members participate in various tech events across the globe as speakers on trending
technologies.
Officially registered as Pvt Ltd in Jan-2015, the community runs with a motto to help cancer children from
the revenue generated from the events/courses/programs organized. Today Cloudnloud is living that
About Me :
Am a tech noob developer when I get an error I find a cheat sheet for syntax.
With diversified skills in eating, sleeping, and coding... Sometimes even running.
Currently sniffing on metaverse, AI, ML, DS, AR/VR, and blockchain techs.
Aadhityaa S.B.
flowcv.me/aadhi
@aadhi06
@aadhi06 my profile