Pandas

Python library for data manipulation and analysis. It can work with many different data types including:

  • symbol separated data (tsv, csv, etc.)
  • ordered and unordered time series data
  • matrix and table data
  • labelled and unlabelled data

Reading tab delimited data

First create a data file. Open a text file 3 lines of text with three words on each line separated by tabs. Then save it as data.tsv. Something like the following

id    name    dob
11    Alice    January
12    Bob    February

code

Introduction to AWS

What is AWS?

Amazon defines Amazon Web Services (AWS) as "a secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow".

What is cloud computing?

On demand delivery of IT resources and applications via the Internet

Resources on cloud

With the traditional model, you need to procure sufficient hardware, bandwidth, and human resources to run the IT infrastructure. Your infrastructure is fixed and financed.

The VirtualBox VM was created with a user that doesn't match the current user running Vagrant.

Error Message

The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.

Cause

You copied someone vagrant box or your own from one machine to another. The box comes with its own settings that are specific to the user so they need to be removed.

Solution

Simply remove the .vagrant directory

$ rm -rf .vagrant

Python3 with MySQL database

If you don't already have MySQL installed, install it with the following commands (mac only):

$ brew info mysql
$ brew install mysql
$ brew tap homebrew/services

Run the following commands to start or stop mysql. Start MySQL before proceeding:

$ brew services stop mysql
$ brew services start mysql

To see available sevices:

$ brew services list

To check MySQL version:

$ mysql -V

Set root password

Python3 with Oracle database

Installation

These instructions are for Mac OS:

First install homebrew. Never use sudo for brew.

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ which brew
/usr/local/bin/brew

Install Python3. The installation comes with pip3.

$ brew install python3
$ which pip3
/usr/local/bin/pip3

Install cx_Oracle, the library that allows python3 to communicate with Oracle database.

File Management

Node uses the fs library to provide rich and powerful file management functionality. First let's a directory and some files:

$ mkdir data; cd data
$ touch provinces.txt capitals.txt

Add the following text to provinces.txt

Alberta
British Columbia
Manitoba
New Brunswick
Newfoundland and Labrador
Nova Scotia
Ontario
Prince Edward Island
Quebec
Saskatchewan

Add the following to capitals.txt

Child Process

The child_process module allows you to communicate with other applications on your system by executing external processes in your environment. There are four kinds of child processes; exec(), spawn(), execFile(), fork(). I will be covering exec() and spawn() here. If a child process will execute once, use exec() function. For example the "cal" command on terminal prints the current month's calendar in the terminal. The command is executed once, prints a result and that's it. If a child process would be running for a long time and printing output several times, use spawn() function.

Events

Node.js is an event-driven system. When you are performing different tasks, different events are emitted. You need to understand those events and how to use them. Events are defined by different modules. For example process.on() is an event. You can also create and use your own events. See example:

var events = require('events');
var eventEmitter = new events.EventEmitter();

eventEmitter.on('bankrupt', function() {
    console.log('You are bankrupt');
});

var networth = -20000;
if (networth < 0) {
    eventEmitter.emit('bankrupt');
}

output:

Pages