done

parent 644ee5f7
{ {
"cells": [], "cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import csv\n",
"with open('myjournal.csv','w',newline='') as fichiercsv:\n",
" writer=csv.writer(fichiercsv)\n",
" writer.writerow(['Date', 'Cahier', 'événement', 'heures_travail'])\n",
" writer.writerow(['04/01/2022', 'projet_arduino', 'rdv_UCA', '8'])\n",
" writer.writerow(['05/01/2022', 'partition_bach', 'zoom_XR', '12'])\n",
" writer.writerow(['06/01/2022', 'cello_vocalise', 'rdv_CIRM', '9'])\n",
" writer.writerow(['07/01/2022', 'formation_éthique', 'cours_en_ligne', '14'])\n",
" writer.writerow(['08/01/2022', 'projet_collège', '', '13'])\n",
" writer.writerow(['09/01/2022', 'partition_bach', 'zoom_prof', '8'])\n",
" writer.writerow(['10/01/2022', 'cello_vocalise', 'répétition_CRR', '6'])\n",
" writer.writerow(['11/01/2022', 'formation_articles', 'concert_CRR', '10'])\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"04/01/2022 projet_arduino\n",
"05/01/2022 partition_bach\n",
"06/01/2022 cello_vocalise\n",
"07/01/2022 formation_éthique\n",
"08/01/2022 projet_collège\n",
"09/01/2022 partition_bach\n",
"10/01/2022 cello_vocalise\n",
"11/01/2022 formation_articles\n"
]
}
],
"source": [
"\n",
" with open('myjournal.csv', newline='') as fichiercsv:\n",
" reader = csv.DictReader(fichiercsv)\n",
" for row in reader:\n",
" print(row['Date'], row['Cahier'])\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rdv_UCA\n",
"zoom_XR\n",
"rdv_CIRM\n",
"cours_en_ligne\n",
"\n",
"zoom_prof\n",
"répétition_CRR\n",
"concert_CRR\n"
]
}
],
"source": [
"\n",
" with open('myjournal.csv', newline='') as fichiercsv:\n",
" reader = csv.DictReader(fichiercsv)\n",
" for row in reader:\n",
" print(row['événement'])"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Date,Cahier,événement,heures_travail\\n']\n",
"['04/01/2022,projet_arduino,rdv_UCA,8\\n', '05/01/2022,partition_bach,zoom_XR,12\\n', '06/01/2022,cello_vocalise,rdv_CIRM,9\\n', '07/01/2022,formation_éthique,cours_en_ligne,14\\n', '08/01/2022,projet_collège,,13\\n', '09/01/2022,partition_bach,zoom_prof,8\\n', '10/01/2022,cello_vocalise,répétition_CRR,6\\n', '11/01/2022,formation_articles,concert_CRR,10\\n']\n"
]
}
],
"source": [
"with open('myjournal.csv') as file:\n",
" content = file.readlines()\n",
"header = content[:1]\n",
"rows = content[1:]\n",
"print(header)\n",
"print(rows)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 15,
"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>Date</th>\n",
" <th>Cahier</th>\n",
" <th>événement</th>\n",
" <th>heures_travail</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>04/01/2022</td>\n",
" <td>projet_arduino</td>\n",
" <td>rdv_UCA</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>05/01/2022</td>\n",
" <td>partition_bach</td>\n",
" <td>zoom_XR</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>06/01/2022</td>\n",
" <td>cello_vocalise</td>\n",
" <td>rdv_CIRM</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>07/01/2022</td>\n",
" <td>formation_éthique</td>\n",
" <td>cours_en_ligne</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>08/01/2022</td>\n",
" <td>projet_collège</td>\n",
" <td>NaN</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>09/01/2022</td>\n",
" <td>partition_bach</td>\n",
" <td>zoom_prof</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>10/01/2022</td>\n",
" <td>cello_vocalise</td>\n",
" <td>répétition_CRR</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>11/01/2022</td>\n",
" <td>formation_articles</td>\n",
" <td>concert_CRR</td>\n",
" <td>10</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Date Cahier événement heures_travail\n",
"0 04/01/2022 projet_arduino rdv_UCA 8\n",
"1 05/01/2022 partition_bach zoom_XR 12\n",
"2 06/01/2022 cello_vocalise rdv_CIRM 9\n",
"3 07/01/2022 formation_éthique cours_en_ligne 14\n",
"4 08/01/2022 projet_collège NaN 13\n",
"5 09/01/2022 partition_bach zoom_prof 8\n",
"6 10/01/2022 cello_vocalise répétition_CRR 6\n",
"7 11/01/2022 formation_articles concert_CRR 10"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data= pd.read_csv(\"myjournal.csv\")\n",
"data\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['Date', 'Cahier', 'événement', 'heures_travail'], dtype='object')"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.columns"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('cello_vocalise', 7.5)\n",
"('formation_articles', 10.0)\n",
"('formation_éthique', 14.0)\n",
"('partition_bach', 10.0)\n",
"('projet_arduino', 8.0)\n",
"('projet_collège', 13.0)\n"
]
}
],
"source": [
"import pandas as pd\n",
"data= pd.read_csv(\"myjournal.csv\")\n",
"\n",
"groupby_gender = data.groupby('Cahier')\n",
"for gender, value in groupby_gender['heures_travail']:\n",
" print((gender, value.mean()))"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10.0\n",
"80\n",
"14\n",
"6\n",
"8\n",
"9.5\n",
"2.7774602993176543\n",
"7.714285714285714\n"
]
}
],
"source": [
"data= pd.read_csv(\"myjournal.csv\")\n",
"\n",
"mean1 = data['heures_travail'].mean()\n",
"sum1 = data['heures_travail'].sum()\n",
"max1 = data['heures_travail'].max()\n",
"min1 = data['heures_travail'].min()\n",
"count1 = data['heures_travail'].count()\n",
"median1 = data['heures_travail'].median() \n",
"std1 = data['heures_travail'].std() \n",
"var1 = data['heures_travail'].var() \n",
"\n",
"print(mean1)\n",
"print(sum1)\n",
"print(max1)\n",
"print(min1)\n",
"print(count1)\n",
"print(median1)\n",
"print(std1)\n",
"print(var1)"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{partition_bach: 2 } {# of rows: 2 }\n"
]
}
],
"source": [
"my_reader = open('myjournal.csv', encoding = 'utf-8')\n",
"rows = 0\n",
"partition_bach = 0\n",
"\n",
"for record in my_reader:\n",
" if record.count('partition_bach') > 0:\n",
" rows += 1\n",
" partition_bach += record.count('partition_bach')\n",
"\n",
"print('{partition_bach: %d } {# of rows: %d }' % (partition_bach, rows))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{projet: 2 } {# of rows: 2 }\n"
]
}
],
"source": [
"my_reader = open('myjournal.csv', encoding = 'utf-8')\n",
"rows = 0\n",
"projet = 0\n",
"\n",
"for record in my_reader:\n",
" if record.count('projet') > 0:\n",
" rows += 1\n",
" projet += record.count('projet')\n",
"\n",
"print('{projet: %d } {# of rows: %d }' % (projet, rows))"
]
},
{
"cell_type": "code",
"execution_count": 82,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{arduino: 1 } {# of rows: 1 }\n"
]
}
],
"source": [
"my_reader = open('myjournal.csv', encoding = 'utf-8')\n",
"rows = 0\n",
"arduino = 0\n",
"\n",
"for record in my_reader:\n",
" if record.count('arduino') > 0:\n",
" rows += 1\n",
" arduino += record.count('arduino')\n",
"\n",
"print('{arduino: %d } {# of rows: %d }' % (arduino, rows))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",
...@@ -16,10 +420,9 @@ ...@@ -16,10 +420,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.3" "version": "3.6.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 2 "nbformat_minor": 2
} }
SN,Name,Contribution
1,Linus Torvalds,Linux Kernel
2,Tim Berners-Lee,World Wide Web
3,Guido van Rossum,Python Programming
Date,Cahier,événement,heures_travail
04/01/2022,projet_arduino,rdv_UCA,8
05/01/2022,partition_bach,zoom_XR,12
06/01/2022,cello_vocalise,rdv_CIRM,9
07/01/2022,formation_éthique,cours_en_ligne,14
08/01/2022,projet_collège,,13
09/01/2022,partition_bach,zoom_prof,8
10/01/2022,cello_vocalise,répétition_CRR,6
11/01/2022,formation_articles,concert_CRR,10
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment