Skip to content

Instantly share code, notes, and snippets.

@mathigatti
Created February 15, 2021 22:32
Show Gist options
  • Save mathigatti/103704d4a7bc367fab1feb5df89f1379 to your computer and use it in GitHub Desktop.
Save mathigatti/103704d4a7bc367fab1feb5df89f1379 to your computer and use it in GitHub Desktop.
Feriados Argentina
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feriados\n",
"https://github.com/pjnovas/nolaborables/tree/master/lib/data/holidays\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"data_2019 = [{\n",
" \"mes\": \"enero\",\n",
" \"01\": \"año-nuevo\"\n",
"},{\n",
" \"mes\": \"febrero\"\n",
"},{\n",
" \"mes\": \"marzo\",\n",
" \"04,05\": \"carnaval\",\n",
" \"24\": \"memoria-verdad-justicia\"\n",
"},{\n",
" \"mes\": \"abril\",\n",
" \"02\": \"veteranos-malvinas\",\n",
" \"18\": \"jueves-santo\",\n",
" \"19\": \"viernes-santo\",\n",
" \"19,20,21,25,26,27\": \"pascuas-judias\",\n",
" \"24\": \"armenia\"\n",
"},{\n",
" \"mes\": \"mayo\",\n",
" \"01\": \"trabajador\",\n",
" \"25\": \"revolucion-mayo\"\n",
"},{\n",
" \"mes\": \"junio\",\n",
" \"04\": \"fiesta-ayuno-ramadan\",\n",
" \"17\": \"martin-guemes\",\n",
" \"20\": \"belgrano\"\n",
"},{\n",
" \"mes\": \"julio\",\n",
" \"08\": \"puente-turistico\",\n",
" \"09\": \"independencia\"\n",
"},{\n",
" \"mes\": \"agosto\",\n",
" \"11\": \"fiesta-sacrificio\",\n",
" \"17\": \"san-martin\",\n",
" \"19\": \"puente-turistico\",\n",
" \"31\": \"año-nuevo-islamico\"\n",
"},{\n",
" \"mes\": \"septiembre\",\n",
" \"29,30\": \"año-nuevo-judio\"\n",
"},{\n",
" \"mes\": \"octubre\",\n",
" \"01\": \"año-nuevo-judio\",\n",
" \"08,09\": \"dia-perdon-judio\",\n",
" \"12\": \"diversidad\",\n",
" \"14\": \"puente-turistico\"\n",
"},{\n",
" \"mes\": \"noviembre\",\n",
" \"18\": \"soberania-nacional\"\n",
"},{\n",
" \"mes\": \"diciembre\",\n",
" \"08\": \"inmaculada-maria\",\n",
" \"25\": \"navidad\"\n",
"}]\n",
"\n",
"data_2020 = [{\n",
" \"mes\": \"enero\",\n",
" \"01\": \"año-nuevo\"\n",
"},{\n",
" \"mes\": \"febrero\",\n",
" \"24,25\": \"carnaval\"\n",
"},{\n",
" \"mes\": \"marzo\",\n",
" \"23\": \"puente-turistico\",\n",
" \"24\": \"memoria-verdad-justicia\",\n",
" \"31\": \"veteranos-malvinas\"\n",
"},{\n",
" \"mes\": \"abril\",\n",
" \"09\": \"jueves-santo\",\n",
" \"10\": \"viernes-santo\",\n",
" \"9,10,15,16\": \"pascuas-judias\",\n",
" \"24\": \"armenia\"\n",
"},{\n",
" \"mes\": \"mayo\",\n",
" \"01\": \"trabajador\",\n",
" \"24\": \"fiesta-ayuno-ramadan\",\n",
" \"25\": \"revolucion-mayo\"\n",
"},{\n",
" \"mes\": \"junio\",\n",
" \"15\": \"martin-guemes\",\n",
" \"20\": \"belgrano\"\n",
"},{\n",
" \"mes\": \"julio\",\n",
" \"09\": \"independencia\",\n",
" \"10\": \"puente-turistico\",\n",
" \"31\": \"fiesta-sacrificio\"\n",
"},{\n",
" \"mes\": \"agosto\",\n",
" \"17\": \"san-martin\",\n",
" \"20\": \"año-nuevo-islamico\"\n",
"},{\n",
" \"mes\": \"septiembre\",\n",
" \"19,20\": \"año-nuevo-judio\",\n",
" \"28\": \"dia-perdon-judio\"\n",
"},{\n",
" \"mes\": \"octubre\",\n",
" \"12\": \"diversidad\"\n",
"},{\n",
" \"mes\": \"noviembre\",\n",
" \"23\": \"soberania-nacional\"\n",
"},{\n",
" \"mes\": \"diciembre\",\n",
" \"07\": \"puente-turistico\",\n",
" \"08\": \"inmaculada-maria\",\n",
" \"25\": \"navidad\"\n",
"}]\n",
"\n",
"data_2021 = [{\n",
" \"mes\": \"enero\",\n",
" \"01\": \"año-nuevo\"\n",
"},{\n",
" \"mes\": \"febrero\",\n",
" \"15,16\": \"carnaval\"\n",
"},{\n",
" \"mes\": \"marzo\",\n",
" \"24\": \"memoria-verdad-justicia\",\n",
" \"28,29,30,31\": \"pascuas-judias\"\n",
"},{\n",
" \"mes\": \"abril\",\n",
" \"01\": [\"jueves-santo\", \"pascuas-judias\"],\n",
" \"02\": [\"viernes-santo\", \"veteranos-malvinas\", \"pascuas-judias\"],\n",
" \"03,04\": \"pascuas-judias\",\n",
" \"24\": \"armenia\"\n",
"},{\n",
" \"mes\": \"mayo\",\n",
" \"01\": \"trabajador\",\n",
" \"24\": [\"fiesta-ayuno-ramadan\", \"puente-turistico\"],\n",
" \"25\": \"revolucion-mayo\"\n",
"},{\n",
" \"mes\": \"junio\",\n",
" \"20\": \"belgrano\",\n",
" \"21\": \"martin-guemes\"\n",
"},{\n",
" \"mes\": \"julio\",\n",
" \"09\": \"independencia\",\n",
" \"31\": \"fiesta-sacrificio\"\n",
"},{\n",
" \"mes\": \"agosto\",\n",
" \"16\": \"san-martin\",\n",
" \"20\": \"año-nuevo-islamico\"\n",
"},{\n",
" \"mes\": \"septiembre\",\n",
" \"19,20\": \"año-nuevo-judio\",\n",
" \"28\": \"dia-perdon-judio\"\n",
"},{\n",
" \"mes\": \"octubre\",\n",
" \"08\": \"puente-turistico\",\n",
" \"11\": \"diversidad\"\n",
"},{\n",
" \"mes\": \"noviembre\",\n",
" \"20\": \"soberania-nacional\",\n",
" \"22\": \"puente-turistico\"\n",
"},{\n",
" \"mes\": \"diciembre\",\n",
" \"08\": \"inmaculada-maria\",\n",
" \"25\": \"navidad\"\n",
"}]\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"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>fecha</th>\n",
" <th>descripción</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>01/1/19</td>\n",
" <td>año-nuevo</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>04/3/19</td>\n",
" <td>carnaval</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>05/3/19</td>\n",
" <td>carnaval</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>24/3/19</td>\n",
" <td>memoria-verdad-justicia</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>02/4/19</td>\n",
" <td>veteranos-malvinas</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>92</th>\n",
" <td>11/10/21</td>\n",
" <td>diversidad</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>20/11/21</td>\n",
" <td>soberania-nacional</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>22/11/21</td>\n",
" <td>puente-turistico</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>08/12/21</td>\n",
" <td>inmaculada-maria</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>25/12/21</td>\n",
" <td>navidad</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>97 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" fecha descripción\n",
"0 01/1/19 año-nuevo\n",
"1 04/3/19 carnaval\n",
"2 05/3/19 carnaval\n",
"3 24/3/19 memoria-verdad-justicia\n",
"4 02/4/19 veteranos-malvinas\n",
".. ... ...\n",
"92 11/10/21 diversidad\n",
"93 20/11/21 soberania-nacional\n",
"94 22/11/21 puente-turistico\n",
"95 08/12/21 inmaculada-maria\n",
"96 25/12/21 navidad\n",
"\n",
"[97 rows x 2 columns]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"\n",
"asd = []\n",
"\n",
"for year, data in [('19',data_2019),('20',data_2020),('21',data_2021)]:\n",
" for i, a in enumerate(data):\n",
" del a[\"mes\"]\n",
" for j in a:\n",
" for dia in j.split(\",\"):\n",
" descr = a[j]\n",
" if type(descr) == list:\n",
" descr = \" / \".join(a[j])\n",
" asd.append({\"fecha\":f\"{dia}/{i+1}/{year}\", \"descripción\": descr})\n",
"\n",
"\n",
"df = pd.DataFrame(asd)\n",
"df.to_csv(\"Desktop/nolaborables.csv\",index=False)\n",
"df"
]
}
],
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment