Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding: utf-8
- # In[6]:
- import pandas as pd
- import math
- import numpy
- # In[3]:
- from matplotlib import pyplot as plt
- # In[24]:
- sample_data=pd.read_csv('DataPlanning.csv',delimiter=';')
- # In[27]:
- #Ligne 1 on créer un tableau vide d'une taille prédifinit de 999 éléments
- chasseurs = [None]*999
- # In[51]:
- #Après pour tout les id_villageois dans excel on créer une variable id
- #on vérifié que id est un nombre et pas une erreur NaN
- #on converti l'id en nombre entier car on en a besoin pour les tableaux
- #et après on prend la case numéro "id" du tableaux des chasseurs et on lui donne la valeur du tableau XCEL pour l'id_villageois ==id
- for id in sample_data.id_villageois:
- if type(id) == float and not math.isnan(id):
- id=int(id)
- chasseurs[id]=sample_data[sample_data.id_villageois==id]
- # In[35]:
- for i in numpy.arange(0, 24):
- horaire=i
- # In[72]:
- class session_chasse:
- def __init__(self, idChasse, depart, retour):
- self.idChasse = idChasse
- self.depart = depart
- self.retour = retour
- class chasseur:
- def __init__ (self, id_vlg, session_de_chasses):
- self.id_vlg = id_vlg
- self.session_de_chasses = session_de_chasses
- def convert_comma_float(toConvert):
- toConvert = toConvert.replace(",", ".")
- try:
- return float(toConvert)
- except ValueError:
- return -1.0
- chasseurs=[None]*999
- for id in sample_data.id_villageois:
- if type(id) == float and not math.isnan(id):
- id=int(id)
- sessions_chasses=[]
- lignes = sample_data[sample_data.id_villageois==id]
- for ligne_chasse in lignes.values:
- idChasse = int(ligne_chasse[5])
- depart = convert_comma_float(ligne_chasse[2])
- retour = convert_comma_float(ligne_chasse[4])
- k = session_chasse(idChasse, depart, retour)
- sessions_chasses.append(k)
- chasseurs[id]= chasseur(id, sessions_chasses)
- # In[ ]:
- print(chasseurs[5].session_de_chasses[2].depart)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement