{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Päivitetty 2023-05-02 / Aki Taanila\n" ] } ], "source": [ "from datetime import datetime\n", "print(f'Päivitetty {datetime.now().date()} / Aki Taanila')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Rivin lisääminen dataframen loppuun" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
KuukausiCO2
2472020-7414.38
2482020-8412.55
2492020-9411.29
2502020-10411.28
2512020-11412.89
\n", "
" ], "text/plain": [ " Kuukausi CO2\n", "247 2020-7 414.38\n", "248 2020-8 412.55\n", "249 2020-9 411.29\n", "250 2020-10 411.28\n", "251 2020-11 412.89" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "# Avaan datan\n", "df = pd.read_excel('https://taanila.fi/CO2.xlsx')\n", "\n", "# Datan loppupää\n", "df.tail()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
KuukausiCO2
2482020-8412.55
2492020-9411.29
2502020-10411.28
2512020-11412.89
2522020-12414.26
\n", "
" ], "text/plain": [ " Kuukausi CO2\n", "248 2020-8 412.55\n", "249 2020-9 411.29\n", "250 2020-10 411.28\n", "251 2020-11 412.89\n", "252 2020-12 414.26" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Rivin lisääminen loppuun (shape[0] antaa rivien lukumäärän)\n", "df.loc[df.shape[0]] = ['2020-12', 414.26]\n", "\n", "# Datan loppupää\n", "df.tail()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Lisätietoa\n", "\n", "Data-analytiikka Pythonilla https://tilastoapu.wordpress.com/python/" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.9" } }, "nbformat": 4, "nbformat_minor": 2 }