{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Arithmetic Operations\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import the LArray library:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from larray import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the `population` array from the `demography_eurostat` dataset:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# load the 'demography_eurostat' dataset\n", "demography_eurostat = load_example_data('demography_eurostat')\n", "\n", "# extract the 'country', 'gender' and 'time' axes\n", "country = demography_eurostat.country\n", "gender = demography_eurostat.gender\n", "time = demography_eurostat.time\n", "\n", "# extract the 'population' array\n", "population = demography_eurostat.population\n", "\n", "# show the 'population' array\n", "population" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basics\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One can do all usual arithmetic operations on an array, it will apply the operation to all elements individually\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 'true' division\n", "population_in_millions = population / 1_000_000\n", "population_in_millions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 'floor' division\n", "population_in_millions = population // 1_000_000\n", "population_in_millions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "