Basics Cheat Sheet Python For Data Science: Strings Lists
Basics Cheat Sheet Python For Data Science: Strings Lists
>>> my_string
>>>
>>>
a = 'is'
b = 'nice'
String Operations
Selecting List Elements Index starts at 0
Learn Python Basics online at www.DataCamp.com >>> my_string * 2
'thisStringIsAwesomethisStringIsAwesome'
Subset
>>> my_string + 'Innit'
'thisStringIsAwesomeInnit'
>>> my_list[1]
#Select item at index 1
>>> x=5
>>> my_list2[1][:2]
>>> x
5
String Methods
>>> my_string.upper()
#String to uppercase
List Operations
Calculations With Variables >>>
>>>
my_string.lower()
#String to lowercase
True
>>> x*2 #Multiplication of two variables
10
25
1
>>> my_list.index(a) #Get the index of an item
Types and Type Conversion Selecting Numpy Array Elements Index starts at 0 >>>
>>>
del(my_list[0:1])
#Remove an item
str()
>>> my_list.insert(0,'!')
#Insert an item
'5', '3.45', 'True' #Variables to strings >>> my_array[1] #Select item at index 1
>>> my_list.sort() #Sort the list
2
int()
Slice
5, 3, 1 #Variables to integers
>>> my_array[0:2]
#Select items at index 0 and 1
float()
5.0, 1.0 #Variables to floats
array([1, 2])
array([1, 4])
True, True, True #Variables to booleans
Leading open data science
Free IDE that is included
Create and share
Numpy Array Operations platform powered by Python with Anaconda documents with live code
>>> my_array * 2
array([2, 4, 6, 8])
Data analysis Scientific computing 2D plotting Machine learning array([6, 8, 10, 12]) >>> help(str)