Task: MIL-005#3
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
> Denne side er genereret fra README.md og wiki/. Ændringer her bliver overskrevet, næste gang wikien udgives.
|
||||||
|
|
||||||
|
> Den engelske side er den gældende; denne oversættelse følger den.
|
||||||
|
|
||||||
|
[English](Home) | Dansk | [Bahasa Melayu](Home.ms)
|
||||||
|
|
||||||
|
# Vejrdata (dag 25)
|
||||||
|
|
||||||
|
At læse CSV-vejrdata i Python. Det er opgaven fra dag 25 i Udemys *100 Days of Code: The Complete Python Pro Bootcamp*. Lektionerne læser en uges vejr fra `weather_data.csv` med Pythons indbyggede `csv`-bibliotek og samler temperaturerne som hele tal, og viser derefter, hvordan biblioteket `pandas` gør det samme på én linje. En tabel er en `DataFrame`, og en kolonne i den er en `Series`; begge kan omdannes til en ordbog og en liste, gennemsnits- og maksimumtemperaturen kan beregnes, rækker kan udvælges ud fra en betingelse, og en `DataFrame` kan oprettes ud fra en ordbog og eksporteres til en CSV-fil.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
*`python -m weather` i en terminal: først csv-delen, derefter pandas-delen.*
|
||||||
|
|
||||||
|
## Hvad programmet skriver
|
||||||
|
|
||||||
|
| Del | Resultat |
|
||||||
|
| --- | --- |
|
||||||
|
| `csv`-biblioteket | Filens rækker og temperaturerne `[12, 14, 15, 14, 21, 22, 24]` |
|
||||||
|
| `pandas` | `DataFrame`, ordbogen og listen med temperaturer |
|
||||||
|
| Statistik | Gennemsnit 17,43 (i hånden og med `mean`) og maksimum 24 |
|
||||||
|
| Rækkeudvælgelse | Mandagens række, den varmeste dags række (søndag), mandag i Fahrenheit (53,6) |
|
||||||
|
| Opret og eksportér | En `DataFrame` med elever og point lavet ud fra en ordbog; skrives kun til en fil med `--export` |
|
||||||
|
|
||||||
|
## Funktioner
|
||||||
|
|
||||||
|
| Funktion | Modul | Lektion |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `read_rows`, `read_temperatures` | `weather.csv_reader` | Læsning med `csv`-biblioteket |
|
||||||
|
| `read_data` | `weather.analysis` | `pandas.read_csv` |
|
||||||
|
| `to_data_dict`, `to_temp_list` | `weather.analysis` | `to_dict`, `to_list` |
|
||||||
|
| `average_temp`, `average_temp_mean`, `max_temp` | `weather.analysis` | Sum og længde, `mean`, `max` |
|
||||||
|
| `row_for_day`, `hottest_row`, `day_in_fahrenheit` | `weather.analysis` | Udvælgelse af rækker |
|
||||||
|
| `create_scores_frame`, `export_frame` | `weather.export` | `DataFrame` ud fra en ordbog, `to_csv` |
|
||||||
|
|
||||||
|
## Kør programmet
|
||||||
|
|
||||||
|
Der skal bruges Python 3.13 eller nyere. `csv`-delen har ingen afhængigheder ved kørsel; `pandas` er et valgfrit tilvalg, som `dev`-tilvalget installerer.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/025-weather.git
|
||||||
|
cd 025-weather
|
||||||
|
python -m venv .venv
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install -e ".[dev]"
|
||||||
|
python -m weather
|
||||||
|
```
|
||||||
|
|
||||||
|
Tilføj `--export new_data.csv` for også at skrive tabellen med point til en fil. Repositoriets README har den fulde opsætning til Windows, Linux og macOS.
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
> This page is generated from README.md and wiki/. Changes made here are overwritten the next time the wiki is published.
|
||||||
|
|
||||||
|
English | [Dansk](Home.da) | [Bahasa Melayu](Home.ms)
|
||||||
|
|
||||||
|
# Weather Data (Day 25)
|
||||||
|
|
||||||
|
Reading CSV weather data in Python. It is the day-25 assignment of Udemy's *100 Days of Code: The Complete Python Pro Bootcamp*. The lectures read the weather of one week from `weather_data.csv` with Python's built-in `csv` library and collect the temperatures as whole numbers, and then show how the `pandas` library does the same in one line. A table is a `DataFrame` and a column of it is a `Series`; both can be converted to a dictionary and a list, the average and the maximum temperature can be computed, rows can be selected by a condition, and a `DataFrame` can be created from a dictionary and exported to a CSV file.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
*`python -m weather` in a terminal: the csv part first, then the pandas part.*
|
||||||
|
|
||||||
|
## What the program prints
|
||||||
|
|
||||||
|
| Part | Result |
|
||||||
|
| --- | --- |
|
||||||
|
| `csv` library | The rows of the file and the temperatures `[12, 14, 15, 14, 21, 22, 24]` |
|
||||||
|
| `pandas` | The `DataFrame`, the dictionary and the list of temperatures |
|
||||||
|
| Statistics | Average 17.43 (by hand and with `mean`) and maximum 24 |
|
||||||
|
| Row selection | The row of Monday, the row of the hottest day (Sunday), Monday in Fahrenheit (53.6) |
|
||||||
|
| Create and export | A `DataFrame` of students and scores made from a dictionary; written to a file only with `--export` |
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
| Function | Module | Lecture |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `read_rows`, `read_temperatures` | `weather.csv_reader` | Reading with the `csv` library |
|
||||||
|
| `read_data` | `weather.analysis` | `pandas.read_csv` |
|
||||||
|
| `to_data_dict`, `to_temp_list` | `weather.analysis` | `to_dict`, `to_list` |
|
||||||
|
| `average_temp`, `average_temp_mean`, `max_temp` | `weather.analysis` | Sum and length, `mean`, `max` |
|
||||||
|
| `row_for_day`, `hottest_row`, `day_in_fahrenheit` | `weather.analysis` | Selecting rows |
|
||||||
|
| `create_scores_frame`, `export_frame` | `weather.export` | `DataFrame` from a dictionary, `to_csv` |
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
Python 3.13 or newer is needed. The `csv` part has no runtime dependencies; `pandas` is an optional extra that the `dev` extra installs.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/025-weather.git
|
||||||
|
cd 025-weather
|
||||||
|
python -m venv .venv
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install -e ".[dev]"
|
||||||
|
python -m weather
|
||||||
|
```
|
||||||
|
|
||||||
|
Add `--export new_data.csv` to also write the scores table to a file. The README of the repository has the full set-up for Windows, Linux and macOS.
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
> Halaman ini dijana daripada README.md dan wiki/. Perubahan di sini akan ditimpa apabila wiki diterbitkan lagi.
|
||||||
|
|
||||||
|
> Halaman Bahasa Inggeris adalah yang rasmi; terjemahan ini mengikutinya.
|
||||||
|
|
||||||
|
[English](Home) | [Dansk](Home.da) | Bahasa Melayu
|
||||||
|
|
||||||
|
# Data Cuaca (hari 25)
|
||||||
|
|
||||||
|
Membaca data cuaca CSV dalam Python. Ia ialah tugasan hari ke-25 dalam *100 Days of Code: The Complete Python Pro Bootcamp* di Udemy. Pelajaran membaca cuaca satu minggu daripada `weather_data.csv` dengan pustaka `csv` terbina dalam Python dan mengumpul suhu sebagai nombor bulat, kemudian menunjukkan bagaimana pustaka `pandas` melakukan perkara yang sama dalam satu baris. Satu jadual ialah `DataFrame` dan satu lajur daripadanya ialah `Series`; kedua-duanya boleh ditukar kepada kamus dan senarai, suhu purata dan suhu maksimum boleh dikira, baris boleh dipilih mengikut syarat, dan `DataFrame` boleh dicipta daripada kamus serta dieksport ke fail CSV.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
*`python -m weather` dalam terminal: bahagian csv dahulu, kemudian bahagian pandas.*
|
||||||
|
|
||||||
|
## Apa yang dipaparkan oleh program
|
||||||
|
|
||||||
|
| Bahagian | Hasil |
|
||||||
|
| --- | --- |
|
||||||
|
| Pustaka `csv` | Baris fail dan suhu `[12, 14, 15, 14, 21, 22, 24]` |
|
||||||
|
| `pandas` | `DataFrame`, kamus dan senarai suhu |
|
||||||
|
| Statistik | Purata 17.43 (secara manual dan dengan `mean`) dan maksimum 24 |
|
||||||
|
| Pemilihan baris | Baris hari Isnin, baris hari terpanas (Ahad), Isnin dalam Fahrenheit (53.6) |
|
||||||
|
| Cipta dan eksport | `DataFrame` pelajar dan skor yang dibuat daripada kamus; ditulis ke fail hanya dengan `--export` |
|
||||||
|
|
||||||
|
## Fungsi
|
||||||
|
|
||||||
|
| Fungsi | Modul | Pelajaran |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `read_rows`, `read_temperatures` | `weather.csv_reader` | Membaca dengan pustaka `csv` |
|
||||||
|
| `read_data` | `weather.analysis` | `pandas.read_csv` |
|
||||||
|
| `to_data_dict`, `to_temp_list` | `weather.analysis` | `to_dict`, `to_list` |
|
||||||
|
| `average_temp`, `average_temp_mean`, `max_temp` | `weather.analysis` | Jumlah dan panjang, `mean`, `max` |
|
||||||
|
| `row_for_day`, `hottest_row`, `day_in_fahrenheit` | `weather.analysis` | Memilih baris |
|
||||||
|
| `create_scores_frame`, `export_frame` | `weather.export` | `DataFrame` daripada kamus, `to_csv` |
|
||||||
|
|
||||||
|
## Jalankan
|
||||||
|
|
||||||
|
Python 3.13 atau lebih baharu diperlukan. Bahagian `csv` tiada kebergantungan semasa dijalankan; `pandas` ialah tambahan pilihan yang dipasang oleh tambahan `dev`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/025-weather.git
|
||||||
|
cd 025-weather
|
||||||
|
python -m venv .venv
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install -e ".[dev]"
|
||||||
|
python -m weather
|
||||||
|
```
|
||||||
|
|
||||||
|
Tambah `--export new_data.csv` untuk turut menulis jadual skor ke fail. README repositori mempunyai persediaan penuh untuk Windows, Linux dan macOS.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
**Weather Data (Day 25)**
|
||||||
|
|
||||||
|
English
|
||||||
|
|
||||||
|
- [Home](Home)
|
||||||
|
|
||||||
|
Dansk
|
||||||
|
|
||||||
|
- [Hjem](Home.da)
|
||||||
|
|
||||||
|
Bahasa Melayu
|
||||||
|
|
||||||
|
- [Utama](Home.ms)
|
||||||
Reference in New Issue
Block a user