Giter Club home page Giter Club logo

camara94 / data_analyse_series_temporelles Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 362 KB

Dans ce tutoriel, nous allons répondre aux questions suivantes: 1. Lire les données Microsoft à l'aide du package **Pandas Data reader** 2. Obtenez le **prix maximum** de l'action de **2017 à 2022** 3. Quelle est la **date du cours le plus élevé** de l'action ? 4. Quelle est la **date du cours le plus bas** de l'action ?

License: MIT License

Jupyter Notebook 100.00%
serie series-forecasting data-visualization data-analysis data-analysis-python data-science data-structures-and-algorithms

data_analyse_series_temporelles's Introduction

Data Analyse Series Temporelles

Dans ce tutoriel, nous allons répondre aux questions suivantes:

  1. Lire les données Microsoft à l'aide du package Pandas Data reader
  2. Obtenez le prix maximum de l'action de 2017 à 2022
  3. Quelle est la date du cours le plus élevé de l'action ?
  4. Quelle est la date du cours le plus bas de l'action ?

Installation du Package pandas_reader


    !pip install pandas-datareader

Importation des Package


	import pandas_datareader as pdr
	import matplotlib.pyplot as plt
	import numpy as np
	plt.style.use('ggplot')
	%matplotlib inline

Site Yahoo Finance

Nous allons récupérer la référence de Microsoft sur le site de yahoo finances à travers ce lien ci-dessous:

https://finance.yahoo.com/quote/MSFT/

Créer le Dataset des Actions de microsoft


	df_microsoft = pdr.get_data_yahoo('MSFT')

Répresantation de la Colonne Close


	plt.figure(figsize=(16,6))
	plt.plot(df_microsoft.loc['2017','Close'])

Quelques Aggrégations


	les_max = df_microsoft.High.resample('W').agg(['max', 'mean'])
	les_min = df_microsoft.High.resample('W').agg(['min'])

Répresentation Personnalisée


	plt.figure(figsize=(16,6))
	les_max['2018']['mean'].plot(c='green')
	plt.fill_between(
    		les_max['2018'].index,
    		les_max['2018']['max'],
    		les_min['2018']['min'],
    		alpha=0.3
	)

Les Prix Minimum et Maximum de 2017 à 2022


	price_max_from_2017_to_2022 = df_microsoft.High.agg(['max'])
	price_min_from_2017_to_2022 = df_microsoft.Low.agg(['min'])

Affichage du Prix Minimum et Maximum


	index_max = df_microsoft[df_microsoft['High'] == price_max_from_2017_to_2022['max']].index
	index_min = df_microsoft[df_microsoft['Low'] == price_min_from_2017_to_2022['min']].index
	plt.figure(figsize=(16, 8))
	plt.plot(df_microsoft.index, df_microsoft.High, c='g')
	plt.scatter(np.array([index_max]), price_max_from_2017_to_2022['max'], lw=13, c="b", label=f'Le {index_max[0].strftime("%d/%m%Y")}')
	plt.scatter(np.array([index_min]), price_min_from_2017_to_2022['min'], lw=13, c="r" , label=f'Le {index_min[0].strftime("%d/%m/%Y")}')
	plt.legend()

Définition d'une periode_fr

Cette fonction permet de retourner la periode en français


	def periode_fr(periode):
    		p = ''
    		if periode == 'Q':
        		p = 'Trimestre'
    		elif periode == 'M':
        		p = 'Mois'
    		elif periode == 'D':
        		p = 'Jour'
    		elif periode == 'W':
        		p = 'Semaine'
    		return p

Répresentation Personnalisée des Colonnes


	def graphiphique_perso(df_microsoft, periode, annee, col, fun_agg, c='g'):
    		data = df_microsoft.resample(periode).agg(['max', 'mean', 'min']);
    		plt.figure(figsize=(16, 5))
    		plt.plot(data[annee][col][fun_agg], label=f'{fun_agg}', c=c)
    		plt.fill_between(
        		data[annee][col].index, 
        		data[annee][col]['min'], 
        		data[annee][col]['max'],
        		alpha=0.3)
    		plt.title(f'L\'analyse de la colonne {col} par {periode_fr(periode)}')
    		plt.legend();

data_analyse_series_temporelles's People

Contributors

camara94 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.