issue171:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue171:python [2021/08/01 19:17] – créée auntiee | issue171:python [2021/08/04 16:31] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | In the poem "to a mouse", | + | **In the poem "to a mouse", |
- | The article you are reading was not my first choice of subjects for this month. In fact, it didn’t make it into the top three subjects. But such is life. When life gives you lemons, what do you do? You make Lemon Drop Martinis. That’s what. | + | The article you are reading was not my first choice of subjects for this month. In fact, it didn’t make it into the top three subjects. But such is life. When life gives you lemons, what do you do? You make Lemon Drop Martinis. That’s what.** |
- | Plotext | + | Dans le poème « to a mouse » (À une souris), Robert Burns écrit « The best laid schemes o' Mice an' Men Gang aft agley ». Certains d' |
+ | |||
+ | L' | ||
+ | |||
+ | **Plotext | ||
I’m always looking for a way to produce plots that I can use easily, quickly and differently. I found what I think is a really good one. ‘Plotext’ plots directly on terminal; it has no dependencies; | I’m always looking for a way to produce plots that I can use easily, quickly and differently. I found what I think is a really good one. ‘Plotext’ plots directly on terminal; it has no dependencies; | ||
Ligne 15: | Ligne 19: | ||
pip install plotext | pip install plotext | ||
- | Once I had the library loaded, I pulled open a ptpython REPL. I borrowed one of the many examples from the repository (shown right). | + | Once I had the library loaded, I pulled open a ptpython REPL. I borrowed one of the many examples from the repository (shown right).** |
- | Working with real data | + | Plotext |
+ | |||
+ | Je suis toujours à la recherche d'un moyen de produire des tracés que je peux utiliser facilement, rapidement et différemment. J'ai trouvé ce que je pense être une très bonne solution. « Plotext » trace directement sur le terminal ; il n'a pas de dépendances et la syntaxe est très similaire à celle de matplotlib. Il fournit également un outil simple en ligne de commande. | ||
+ | |||
+ | Je n'ai pas eu beaucoup de temps pour tester et examiner complètement plotext, mais lorsque vous arriverez à la fin de cet article, vous verrez qu'il n'est pas très difficile à utiliser. | ||
+ | |||
+ | Vous pouvez voir le projet à l' | ||
+ | |||
+ | Il est facile à installer en utilisant pip (ou pip3). | ||
+ | |||
+ | pip install plotext | ||
+ | |||
+ | Une fois la bibliothèque chargée, j'ai ouvert un REPL ptpython. J'ai emprunté l'un des nombreux exemples du dépôt (illustré à droite). | ||
+ | |||
+ | |||
+ | **Working with real data | ||
I wanted to see just how easy it is using some real data. I did a quick web search for the latest Covid-19 data for confirmed cases in Texas from March 3, 2020 until July 12, 2021. It was a very large amount of data, so I simply pulled up the data in a spreadsheet and pulled the totals for all of Texas for the last 40 days. Then I threw together the following program (next page, top right). | I wanted to see just how easy it is using some real data. I did a quick web search for the latest Covid-19 data for confirmed cases in Texas from March 3, 2020 until July 12, 2021. It was a very large amount of data, so I simply pulled up the data in a spreadsheet and pulled the totals for all of Texas for the last 40 days. Then I threw together the following program (next page, top right). | ||
Ligne 23: | Ligne 42: | ||
You can see that the ‘last 40 days’ shows what the news is reporting. Despite the attempts to control Covid-19, the number of confirmed cases rose at a fairly steep rate. | You can see that the ‘last 40 days’ shows what the news is reporting. Despite the attempts to control Covid-19, the number of confirmed cases rose at a fairly steep rate. | ||
- | Next, I tried to pull the data just for one county in Texas (bottom right). Harris county is where most of Houston is located. Houston has over 4 million residents and is the fourth largest city in the United States. | + | Next, I tried to pull the data just for one county in Texas (bottom right). Harris county is where most of Houston is located. Houston has over 4 million residents and is the fourth largest city in the United States.** |
- | This time I pulled only 28 days worth of data. This plot shows that, in Harris county, things were starting to stabilize and actually going down until around the 28th of June, then started going up at a fairly quick rate. | + | Travailler avec des données réelles |
+ | |||
+ | Je voulais voir à quel point c'est facile en utilisant des données réelles. J'ai effectué une recherche rapide sur Internet pour trouver les dernières données concernant les cas confirmés de Covid-19 au Texas du 3 mars 2020 au 12 juillet 2021. Comme il s' | ||
+ | |||
+ | Vous pouvez voir que les « 40 derniers jours » montrent ce que les nouvelles rapportent. Malgré les tentatives de contrôle du Covid-19, le nombre de cas confirmés a augmenté à un rythme assez rapide. | ||
+ | |||
+ | Ensuite, j'ai essayé d' | ||
+ | |||
+ | |||
+ | **This time I pulled only 28 days worth of data. This plot shows that, in Harris county, things were starting to stabilize and actually going down until around the 28th of June, then started going up at a fairly quick rate. | ||
Finally, I pulled the data for Hays County in Texas (next page, top right). Hays county is a fairly small county in terms of population, only around 157,000. Many of the residents of Hays county are college students. | Finally, I pulled the data for Hays County in Texas (next page, top right). Hays county is a fairly small county in terms of population, only around 157,000. Many of the residents of Hays county are college students. | ||
- | Again, the number of confirmed cases went from 17150 to 19230 in a period of 103 days. While that’s only 2088 more cases over the sample period, I find it interesting that the number of cases were rising at a fairly steady rate until about the time that the students started heading home for the summer break. Then the number of cases still went up but at a much slower rate. | + | Again, the number of confirmed cases went from 17150 to 19230 in a period of 103 days. While that’s only 2088 more cases over the sample period, I find it interesting that the number of cases were rising at a fairly steady rate until about the time that the students started heading home for the summer break. Then the number of cases still went up but at a much slower rate.** |
- | As you can see, with a very little amount of effort, you can get reasonable plots. According to the repository site, you can do scatter plots, line plots, log plots, stem plots, multiple data sets, double Y axis plots, bar plots, histogram plots, set the data ticks to custom values, date/time plots, multiple subplots, plot streaming data, and more. | + | Cette fois-ci, je n'ai utilisé que 28 jours de données. Ce graphique montre que, dans le comté de Harris, les choses commençaient à se stabiliser et baissaient en fait jusqu' |
+ | |||
+ | Enfin, j'ai extrait les données du comté de Hays au Texas (page suivante, en haut à droite). Le comté de Hays est un comté assez petit en termes de population, de l' | ||
+ | |||
+ | Là encore, le nombre de cas confirmés est passé de 17 150 à 19 230 en l' | ||
+ | |||
+ | **As you can see, with a very little amount of effort, you can get reasonable plots. According to the repository site, you can do scatter plots, line plots, log plots, stem plots, multiple data sets, double Y axis plots, bar plots, histogram plots, set the data ticks to custom values, date/time plots, multiple subplots, plot streaming data, and more. | ||
It looks like the developers are determined to continue updating the package, since everything on the site seems to have been updated within the last couple of months. They are currently on version 3.13. | It looks like the developers are determined to continue updating the package, since everything on the site seems to have been updated within the last couple of months. They are currently on version 3.13. | ||
Ligne 39: | Ligne 73: | ||
The code that I used to produce the charts can be found at https:// | The code that I used to produce the charts can be found at https:// | ||
- | Until next time, as always; stay safe, healthy, positive and creative! | + | Until next time, as always; stay safe, healthy, positive and creative!** |
+ | |||
+ | Comme vous pouvez le constater, avec très peu d' | ||
+ | |||
+ | Il semble que les développeurs soient déterminés à poursuivre la mise à jour du paquet, puisque tout sur le site semble avoir été mis à jour au cours des deux derniers mois. Ils en sont actuellement à la version 3.13. | ||
+ | |||
+ | C'est un excellent petit paquet et j'ai l' | ||
+ | |||
+ | Le code que j'ai utilisé pour produire les graphiques se trouve à l' | ||
+ | |||
+ | Jusqu' | ||
+ | |||
+ | |||
+ | //Encarts p 21 en haut et en bas :// | ||
+ | |||
+ | **When I ran the program, this is the plot that I got:** | ||
+ | |||
+ | Quand je lance le programme, voici le tracé que j'ai obtenu : | ||
+ | |||
+ | |||
+ | //Encart p 22 :// | ||
+ | |||
+ | **This dataset has 103 data points in it. | ||
+ | Here’s what the plot looks like:** | ||
+ | Cet ensemble de données a 103 points. | ||
+ | Voici à quoi ressemble le tracé : |
issue171/python.1627838266.txt.gz · Dernière modification : 2021/08/01 19:17 de auntiee