Created
November 15, 2022 04:50
-
-
Save scidam/84d5af15a2c0722ac669e315bc9f989b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 31, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pandas as pd\n", | |
| "from functools import partial\n", | |
| "s_na_mean = partial(pd.Series.max, skipna = True)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 32, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "fname_list = [\"Yuzhno-Sakhalinsk_day_temperature.csv\", \"Nevelsk_day_temp.csv\", \"Iljinskiy_day_temp.csv\"]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 33, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "for fname in fname_list:\n", | |
| " df = pd.read_csv(fname, sep=';')\n", | |
| " df.groupby(['year', 'month']).aggregate(s_na_mean)[['temp_min', 'temp_avg', 'temp_max']].to_csv(f'{fname[:5]}_max.csv')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 34, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>year</th>\n", | |
| " <th>month</th>\n", | |
| " <th>day</th>\n", | |
| " <th>temp_min</th>\n", | |
| " <th>temp_avg</th>\n", | |
| " <th>temp_max</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>1942</td>\n", | |
| " <td>7</td>\n", | |
| " <td>3</td>\n", | |
| " <td>9.5</td>\n", | |
| " <td>12.9</td>\n", | |
| " <td>16.6</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>1942</td>\n", | |
| " <td>7</td>\n", | |
| " <td>4</td>\n", | |
| " <td>10.4</td>\n", | |
| " <td>12.1</td>\n", | |
| " <td>14.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>1942</td>\n", | |
| " <td>7</td>\n", | |
| " <td>5</td>\n", | |
| " <td>8.3</td>\n", | |
| " <td>9.9</td>\n", | |
| " <td>11.5</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>1942</td>\n", | |
| " <td>7</td>\n", | |
| " <td>6</td>\n", | |
| " <td>8.0</td>\n", | |
| " <td>8.5</td>\n", | |
| " <td>10.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>1942</td>\n", | |
| " <td>7</td>\n", | |
| " <td>7</td>\n", | |
| " <td>8.0</td>\n", | |
| " <td>8.7</td>\n", | |
| " <td>10.4</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>29032</th>\n", | |
| " <td>2021</td>\n", | |
| " <td>12</td>\n", | |
| " <td>27</td>\n", | |
| " <td>-12.2</td>\n", | |
| " <td>-10.5</td>\n", | |
| " <td>-8.7</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>29033</th>\n", | |
| " <td>2021</td>\n", | |
| " <td>12</td>\n", | |
| " <td>28</td>\n", | |
| " <td>-15.1</td>\n", | |
| " <td>-13.6</td>\n", | |
| " <td>-12.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>29034</th>\n", | |
| " <td>2021</td>\n", | |
| " <td>12</td>\n", | |
| " <td>29</td>\n", | |
| " <td>-15.6</td>\n", | |
| " <td>-13.3</td>\n", | |
| " <td>-12.2</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>29035</th>\n", | |
| " <td>2021</td>\n", | |
| " <td>12</td>\n", | |
| " <td>30</td>\n", | |
| " <td>-14.3</td>\n", | |
| " <td>-12.8</td>\n", | |
| " <td>-11.2</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>29036</th>\n", | |
| " <td>2021</td>\n", | |
| " <td>12</td>\n", | |
| " <td>31</td>\n", | |
| " <td>-15.3</td>\n", | |
| " <td>-13.5</td>\n", | |
| " <td>-11.4</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>29037 rows × 6 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " year month day temp_min temp_avg temp_max\n", | |
| "0 1942 7 3 9.5 12.9 16.6\n", | |
| "1 1942 7 4 10.4 12.1 14.0\n", | |
| "2 1942 7 5 8.3 9.9 11.5\n", | |
| "3 1942 7 6 8.0 8.5 10.0\n", | |
| "4 1942 7 7 8.0 8.7 10.4\n", | |
| "... ... ... ... ... ... ...\n", | |
| "29032 2021 12 27 -12.2 -10.5 -8.7\n", | |
| "29033 2021 12 28 -15.1 -13.6 -12.0\n", | |
| "29034 2021 12 29 -15.6 -13.3 -12.2\n", | |
| "29035 2021 12 30 -14.3 -12.8 -11.2\n", | |
| "29036 2021 12 31 -15.3 -13.5 -11.4\n", | |
| "\n", | |
| "[29037 rows x 6 columns]" | |
| ] | |
| }, | |
| "execution_count": 34, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "pd.read_csv(\"Iljinskiy_day_temp.csv\", sep=';')" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "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.7.9" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment