Thursday, February 27, 2020

Census, the Low Response Score in NYC

The Census Bureau developed the Low Response Score (LRS) as a metric to identify the hard-to-survey areas. The higher the LRS value, the lower is the propensity to respond in the census. The following map represents the quantiles of the LRS, breakdown by tracts, in the five boroughs of New York. The darker tracts are the areas where is more difficult to get responses in the census. To create this map I made use of QGIS.

data source: census.gov


Thursday, February 13, 2020

date_part #8 of #100PostgreSQLFunctions

This post is a part of the project #100PostgreSQLFunctions, which aims to explain the meaning of 100 PostgreSQL functions and how to use them. For the full list of functions click here.

date_part is a function to extract subfields of a value, which has to be one of the following datatypes: date, timestamp or interval.
This function has two argument:
  • subfield is the part of the value we want to extract
  • source represents the value from which we want to extract the subfield

Examples:

SELECT
    date_part('month', '2/20/2019'::date);

 date_part
-----------
         2
(1 row)


SELECT
    date_part('second', '2/20/2019 12:5:34'::timestamp);

 date_part
-----------
        34
(1 row)


SELECT
    date_part('day', '6 years 5 months 4 days'::interval);

 date_part
-----------
         4
(1 row)

date_trunc #7 of #100PostgreSQLFunctions

This post is a part of the project #100PostgreSQLFunctions, which aims to explain the meaning of 100 PostgreSQL functions and how to use them. For the full list of functions click here.

date_trunc is a function to truncate a timestamp value, or an interval value, with a level of precision.
This function has two argument:
  • datapart is the level of precision
  • field is the timestamp value or the interval value to truncate

Examples:

SELECT
    date_trunc('month', '1/30/2020'::timestamp);

     date_trunc   
---------------------
 2020-01-01 00:00:00
(1 row)


SELECT
    date_trunc('month', '6 years 3 months 30 days'::interval);

   date_trunc 
----------------
 6 years 3 mons
(1 row)

EXTRACT #6 of #100PostgreSQLFunctions

This post is a part of the project #100PostgreSQLFunctions, which aims to explain the meaning of 100 PostgreSQL functions and how to use them. For the full list of functions click here.

EXTRACT is a function to retrieve subfields of a value, which has to be one of the following datatypes: date, timestamp or interval. By parenthesis, we need to specify the subfield to extract, and from which value we want to get it.

Examples:

SELECT
    EXTRACT(month from '2/20/2019'::date);

 date_part
-----------
         2
(1 row)


SELECT
    EXTRACT(second from '2/20/2019 12:5:34'::timestamp);

 date_part
-----------
        34
(1 row)


SELECT
    EXTRACT(day from '6 years 5 months 4 days'::interval);

 date_part
-----------
         4
(1 row)