Computing with Data
elgeish
533.8K views
02 Chapter 3
Bash - Introduction Bash - Variables Bash - Pipes Bash - Loops Bash - Conditional Logic Bash - Aliases Command Prompt - Introduction Command Prompt - Variables Command Prompt - Pipes Command Prompt - Loop Command Prompt - Conditional Logic PowerShell - Introduction PowerShell - Pipes PowerShell - Variables PowerShell - Loops PowerShell - Conditional Logic Processes in Linux - Part I Processes in Linux - Part II Processes in Windows Files in Linux Displaying Files Moving, Copying, and Removing Files and Directories Wildcard Characters Soft Links Listing Directory Contents The PATH Environment Variable Compression in Linux Bash Initialization File Script Files Files in Windows Hierarchy of Directories Compression in Windows Users and Permissions in Linux Users and Permissions in Windows Redirecting Input and Output in Linux Redirecting Input and Output in Windows Working on Remote Linux Computers
03 Chapter 4
Compilation Variables Scope Operators Type Conversions References Pointers Arrays Preprocessor and Namespaces - Part I Preprocessor and Namespaces - Part II Strings - Part I Strings - Part II Input - Part I Input - Part II Input - Part III Output If-Else Clauses While-Loops For-Loops - Part I For-Loops - Part II For-Loops - Part III Functions Return Value Function Parameters Function Definition and Function Declaration Scope of Function Variables Pointer Parameters Reference Parameters Recursion - Part I Recursion - Part II Recursion - Part III Recursion - Part IV Passing Arguments to Main Overloading Functions Structs - Part I Structs - Part II Structs - Part III Structs - Part IV Structs - Part V Classes Constructors - Part I Constructors - Part II The Destructor The Copy Constructor The Converting Constructor The Implicit Converting Constructor The Explicit Converting Constructor Operator Overloading Friend Functions and Classes Inheritance Polymorphism Static Binding Virtual Functions Static Variables and Functions - Part I Static Variables and Functions - Part II Dynamic Memory Allocation - Part I Dynamic Memory Allocation - Part II Dynamic Memory Allocation - Part III Smart Pointers - Part I Smart Pointers - Part II Smart Pointers - Part III Template Functions - Part I Template Functions - Part II Template Classes Vectors Arrays Sets Maps - Part I Maps - Part II Unordered Maps
05 Chapter 6
Getting Started Objects Importing Modules Executing Shell Commands Scalar Data Types Strings Duck Typing Tuples Lists Ranges Slicing Sets Dictionaries Counters Dictionaries with Default Values Hashable Objects List Comprehensions Set Comprehensions Dictionary Comprehensions Nested Comprehensions Control Flow The Empty Statement Functions - Part I Functions - Part II Functions - Part III Classes Inheritance The Empty Class The NumPy Package Linear Algebra Random Number Generation The SciPy Package The pandas Package The scikit-learn Package Clustering Classification Regression Reading and Writing Data in Text Format Reading and Writing Ndarrays Reading and Writing Dataframes Material Differences between Python 3 and 2
07 Chapter 8
Graphing Data in R Datasets Packages Strip Plots Histograms Line Plots Kernel Functions Smoothing Histograms Using Gaussian Kernels Smoothing Histograms Using qplot Smoothing Histograms Using ggplot Scatter Plots Smoothing Scatter Plots Facets All-Pairs Relationships Contour Plots Box Plots qq-Plots Devices Data Preparation Graphing Data in Python Line Plots Histograms Contour Plots Surface Plots
08 Chapter 9
Missing Data in R - Part I Missing Data in R - Part II Missing Data in Python Outliers Skewness and Power Transformation - Part I Skewness and Power Transformation - Part II Binning Indicator Variables Random Sampling, Partitioning, and Shuffling Concatenations and Joins Reshaping Data The Split-Apply-Combine Framework
09 Chapter 10
Thread Safety - Part I Thread Safety - Part II Volatility - Part I Volatility - Part II Synchronization Ineffectual Synchronization - Part I Ineffectual Synchronization - Part II Ineffectual Synchronization - Part III Synchronization vs. Volatility Starvation Deadlocks - Part I Deadlocks - Part II Deadlocks - Part II The Producer-Consumer Problem - Part I The Producer-Consumer Problem - Part II The Producer-Consumer Problem - Part III The Producer-Consumer Problem - Part IV The Producer-Consumer Problem - Part V The Producer-Consumer Problem - Part VI Reader-Writer Locks - Part I Reader-Writer Locks - Part II Reader-Writer Locks - Part III Reader-Writer Locks - Part IV Reentrant Locks - Part I Reentrant Locks - Part II Reentrant Locks - Part III Reentrant Locks - Part IV Thread Pools - Part I Thread Pools - Part II Thread Pools - Part III Scheduled Executor Services Futures Streams ParSeq - Part I ParSeq - Part II ParSeq - Part III ParSeq - Part IV File Locks Distributed Locks Linearizable Counters
Dictionaries
A dictionary is an unordered, mutable compound data type representing a set of (key, value) pairs, where each key may appear at most one time:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Example: create 3 dicts with three key-value pairs:
# ('Na', 11), ('Mg', 12), and ('Al', 13)
d = dict((('Na', 11), ('Mg', 12), ('Al', 13)))
e = {'Na': 11, 'Mg': 12, 'Al': 13}
f = dict(Na=11, Mg=12, Al=13)
print(d == e == f) # check equivalence
print(d.keys()) # print all keys (unordered)
print(d.values()) # print all respective values
# Example: create a dict with two key-value pairs
d = {'Na': 11, 'Mg': 12, 'Al': 13}
print(d['Na']) # retrieve value corresponding to key 'Na'
print('Li' in d) # check if 'Li' is a key in dict d
# Example: create a dictionary with two key-value pairs
d = {'Na': 11, 'Mg': 12, 'Al': 13}
d['Li'] = 3 # add the key value pair ('Li', 3)
del d['Na'] # remove key-value pair corresponding to key 'Na'
print(d) # print dictionary
# Example: create a dictionary from two lists: keys and values
keys = ['Na', 'Mg', 'Al']
values = [11, 12, 13]
d = dict(zip(keys, values))
print(d)
# Example: iterate over all items in a dictionary
d = dict(Na=11, Mg=12, Al=13)
# iterate over all items in d
for key, value in d.items():
print(key, value)
# Example: a double lookup (an anti-pattern)
d = dict(Na=11, Mg=12, Al=13)
for key in d: # similar to for key in iter(d):
print(key, d[key])
# Example: a double lookup (again)
counts = dict(apples=3, oranges=5, bananas=1)
key = 'apples'
if key in counts: # first lookup
print(counts[key]) # second lookup
else:
print(0)
# Example: avoiding double lookups
counts = dict(apples=3, oranges=5, bananas=1)
key = 'apples'
print(counts.get(key, 0)) # single lookup
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Suggested playgrounds