Opublikowano:
Aktualizacja:
W pierwszej kolejności, najlepiej poznać podstawową składnię języka Python oraz przykłady jej użycia. W sieci znaleźć można wiele darmowych kursów Pythona (większość w języku angielskim), przykładowo:
https://www.w3schools.com/python
W tym blogu prezentowane przykłady zapisane są w notatniku Jupyter. Można użyć gotowy, skonfigurowany notatnik taki jak Google Colab (należy posiadać konto w Google).
https://colab.research.google.com
Po otwarciu Colab, wybieramy przycisk „Nowy notatnik”, i możemy już przystąpić do programowania.
Importowanie danych.
W sieci znaleźć można znaleźć wiele witryn, gdzie można za darmo pobrać podstawowe dane historyczne (np. na stronie https://stooq.pl).
Dla przykładu pobierzemy dane historyczne dla niemieckiego DAX – dzienne od roku 1959.
Poniżej wypunktowano kolejne kroki:
1. Pobieramy plik w formacie „.csv”.
2. Zmieniamy nazwę na “dax.csv”.
3. Tworzymy na dysku Google (Google Drive) folder o nazwie “dane_historyczne”.
4. Kopiujemy do nowo utworzonego folderu plik “dax.csv”.
5. W notatniku Colab importujemy bibliotekę “pandas”, dane z pliku zapisywane są w strukturze typu Dataframe – nazwanej przez nas – “df”.
import pandas as pd
df=pd.read_csv('/content/drive/My Drive/dane_historyczne/dax.csv')
6. W celu zobaczenia, czy dane zostały wczytane należy wpisać komendę:
df.head()
7. Po zatwierdzeniu komendy otrzymujemy następujący output:
Poniżej znajduje się wideo pokazujące powyższą instrukcję krok po kroku:
Możemy sprawdzić statystykę danych, które importowaliśmy:
df.describe()
Warto sprawdzić, czy liczba wierszy (count) w każdej kolumnie jest równa. W kolumnie “Wolumen” dane są niepełne – wartości pojawiają się tylko w 4854 wierszach.
Możemy usunąć kolumnę “Wolumen”:
df=df.drop(['Wolumen'], axis=1)
df
Otrzymujemy odpowiedź:
Jeśli dane nie zawierają błędów, gotowe są do dalszego przetwarzania.
© 2025 All Rights Reserved.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Kopiowanie wszystkich kodów tylko dla użytkowników PREMIUM.