Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
da84ababf0696af51bddad556af86353
mooc-rr
Commits
20049083
Commit
20049083
authored
Nov 20, 2022
by
Louis Lacoste
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Première analyse
parent
912e8519
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
14 deletions
+69
-14
analyse-journal.org
module2/exo4/analyse-journal.org
+69
-14
No files found.
module2/exo4/analyse-journal.org
View file @
20049083
...
...
@@ -33,23 +33,78 @@ head -n 5 data.csv
#+NAME: import-python
#+begin_src python :results output :session :exports both :dir /home/polarolouis/Documents/MOOC/RR/mooc-rr/module2/exo4
import csv
from collections import Counter
temporaryList = []
with open('data.csv', 'r', encoding='utf8') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
print(row)
temporaryList.append(row[0])
tagCount = Counter(temporaryList)
tagList = []
countList = []
for tag in tagCount:
tagList.append(tag)
countList.append(tagCount[tag])
#+end_src
Ici on convertit les données en dataframe =pandas= afin de pouvoir faire
l'affichage plus facilement.
#+RESULTS: import-python
#+begin_example
['informatique']
['wikipedia']
['biologie']
['virus']
['allergie']
['biologie']
['LOGBOOK']
['END']
['LOGBOOK']
['END']
#+end_example
#+NAME: conversion-dataframe
#+begin_src python :results output :session :exports both
import pandas as pd
preDataframe = dict(tagCount)
print(preDataframe)
tagCountDataframe = pd.DataFrame.from_dict({'tags':list(preDataframe), 'values':list(preDataframe.values())})
tagCountDataframe['values'] = pd.to_numeric(tagCountDataframe['values'])
print(tagCountDataframe)
#+end_src
#+RESULTS: conversion-dataframe
: {'informatique': 1, 'wikipedia': 1, 'biologie': 2, 'virus': 1, 'allergie': 1, 'LOGBOOK': 2, 'END': 2}
: tags values
: 0 informatique 1
: 1 wikipedia 1
: 2 biologie 2
: 3 virus 1
: 4 allergie 1
: 5 LOGBOOK 2
: 6 END 2
* Affichage des données
** Diverses infos
#+begin_src python :results output :session :exports both
print(f"Les tags les plus cités : {tagCount.most_common(3)}")
#+end_src
#+RESULTS:
: Les tags les plus cités : [('biologie', 2), ('LOGBOOK', 2), ('END', 2)]
** Graphiques
#+begin_src python :results file :session :var matplot_lib_filename=(org-babel-temp-file "figure" ".png") :exports both
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.tight_layout()
# Affichage
ax = tagCountDataframe.plot(x="tags", y="values", kind='bar')
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+RESULTS:
[[file:/tmp/babel-DfWAKd/figureDe0QxU.png]]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment