arundhaj

all that is technology

Split array based on difference with NumPy

 

I had a NumPy array of numbers, which I had to split based on the change of value.

For example, consider an array as shown below.

values = [112.0, 111.0, 113.0, 111.0, 112.0, 112.0, 112.0, 113.0, 113.0,
       113.0, 114.0, 114 …

Import postgres table to HDFS using sqoop

 

Importing data from postgres tables into HDFS using sqoop could be done with the following steps.

Make sure postgres jdbc connector is available in /usr/share/java directory.

To list all available tables in the postgres database

$ sqoop list-tables \
    --connect jdbc:postgresql://hostname.com/databaseName \
    --username myUserName \
    --password myPassword

To …

Categorizing and summing data in d3js

 

Categorizing an array into different buckets in d3js with d3.nest.

For example, consider a dataset that contains an array of integers ranging values from 1 to 200. If we had to group this array into the following four buckets, as defined as;

  • value >= 150, categorize as excess-heat
  • value >= 140 …

Connect remote postgresql server with pgAdmin

 

When trying to connect remote postgresql server with pgAdmin, leads to "Unable to connect" error.

To enable pgAdmin to connect, edit the following configuration in the server:

$ sudo vim /etc/postgresql/9.3/main/postgresql.conf
   listen_address = '*'

$ sudo vim /etc/postgresql/9.3/main/pg_hba.conf
   local    all     postgresql          trust …

SSLProtocolException handshake alert

 

I was getting the below mentioned exception on my Java client which is trying to establish URL connection to a server.

javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name

The Java client was actually trying to get an XML from the the URL and store it locally in a file as …

PyTypeObject base of Python

 

PyTypeObject is a structure that defines the basic building blocks of Python, Types.

The definition as found in Include/Object.h file:

typedef struct _typeobject {
    PyObject_VAR_HEAD
    const char *tp_name; /* For printing, in format "<module>.<name>" */
    Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */

    /* Methods to implement standard operations */

    destructor …

Pandas with Postgres datasource

 

We would be getting data from different sources for doing data analysis. Most common being from files, we might even source from databases.

This post will show how to load data from postgres database to pandas DataFrame. pandas is a python based data analysis tool.

import psycopg2 as pg
import …