0% found this document useful (0 votes)
4 views1 page

Essential Python Libraries for Data Science

This document provides an introduction to the libraries and basic concepts of Python for data science, including the importation of libraries such as NumPy, variables and data types, strings, lists, and basic operations with NumPy arrays such as selection, indexing, and calculations. It also presents concepts such as graphics, machine learning, and data analysis.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Essential Python Libraries for Data Science

This document provides an introduction to the libraries and basic concepts of Python for data science, including the importation of libraries such as NumPy, variables and data types, strings, lists, and basic operations with NumPy arrays such as selection, indexing, and calculations. It also presents concepts such as graphics, machine learning, and data analysis.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Libraries

for Data Science: Reference Sheet Import libraries

Basic Python >>> import numpy


>>> import numpy as np Scientific computing
Learn Python for Data Science [Link]

Selective importation

Variables and data types >>> from math import pi


Variable assignment 2D Graphics
>>> x=5
>>> x
5

Calculations with variables


>>> x+2 Sum of two variables
7
Machine Learning Data Analysis
x-2 Subtraction of two variables
3
>>> x*2 Multiplication of two variables
10
x squared Install Python
Exponentiation of a variable
25
x mod 2 Remainder of a variable
1
>>> x/float(2) Division of a variable
2.5

Types and type conversion


str() '5', '3.45', 'True' Variables to strings
int() 5, 3, 1 Variables as integers
float() 5.0, 1.0 Floating point variables Open platform of Development environment Create and share documents
bool() True, True, True Boolean variables data science with python included with Anaconda with live code,
visualizations, text etc
Chains
>>> my_string = 'thisStringIsAwesome'
>>> my_string Help
thisStringIsAwesome
>>> help(str)
String operations

>>> my_string * 2 NumPy Matrices


thisStringIsAwesomethisStringIsAwesome
my_string + 'Innit' >>> my_list = [1, 2, 3, 4]
thisStringIsAwesomeIsn't it >>> my_array = [Link](my_list)
'm' in my_string
my_2darray = [Link]([[1,2,3],[4,5,6]])
True

Indices start with 0


Selecting Elements of NumPy Arrays
my_string[3]
my_string[4:9] Select

String methods my_array[1] Select element at index 1


2
>>> MY_STRING.UPPER() Chain to uppercase
>>> my_string.lower() Chain to lowercase
>>> my_string.count('w') Count string elements Short
my_string.riplaci('i', 'i') Replace string elements Select elements at indices 0 and 1
>>> my_string.strip() Remove blank spaces >>> my_array[0:2]
[1, 2]
Lists
is Select 2D matrix
nice my_2darray [filas, columnas]
>>> my_list =['my', 'list', a, b] my_2darray[:,0]
>>> my_list2 =[[4,5,6,7], [3,4,5,6]] [1, 4]

Selecting elements from the list


Select
NumPy Operations
my_list[1]
my_list[-3] Select element at index 1
Select the 3rd to last element my_array > 3
Short
[False, False, False, True]
my_list[1:3]
>>> my_list[1:] Select elements at indices 1 and 2 >>> my_array * 2
>>> my_list[:3] Select elements after index 0 array([2, 4, 6, 8])
>>> my_list[:] Select elements before index 3 >>> my_array + [Link]([5, 6, 7, 8])
Select lists within lists Copy my_list [6,8,10,12]
my_list2[1][0]
my_list2[1][:2]

List operations NumPy Functions


>>> my_list + my_list
["my","list","is","nice","my","list","is","nice"] >>> my_array.shape Matrix dimensions
my_list * 2 >>> [Link](other_array) Add elements to an array
["my","list","is","nice","my","list","is","nice"] >>> [Link](my_array, 1, 5) Insert elements into an array
my_list2 > 4 >>> [Link](my_array,[1]) Remove elements from an array
True >>> [Link](my_array) Average of the matrix
>>> [Link](my_array) Median of the matrix
List methods Get the index of an element Correlation coefficient
>>> my_array.corrcoef()
>>> my_list.index(a)
Count an element >>> [Link](my_array) Standard Deviation
>>> my_list.count(a)
Add an item to the list
my_list.append('!')
Remove an element
my_list.remove('!')
Remove an element
>>> del(my_list[0:1])
Invert the list
my_list.reverse()
Add an element
>>> my_list.extend('!')
Remove an element
>>> my_list.pop(-1)
Insert an element
my_list.insert(0,'!')
Sort the list Learn Python for Data Science [Link]
>>> my_list.sort()

You might also like