Exemple #1
0
#    By: tbrizon <*****@*****.**>            +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2019/11/08 17:02:12 by tbrizon           #+#    #+#              #
#    Updated: 2019/12/02 13:36:36 by tbrizon          ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

from FileLoader import FilerLoader as fl
import pandas as pd


def YoungestFellah(data, year):
    yf = {
        'f' : [],
        'm' : []
    }

    m = data.loc[(data['Year'] == year) & (data['Sex'] == 'M')].sort_values(by =['Age'])
    f = data.loc[(data['Year'] == year) & (data['Sex'] == 'F')].sort_values(by =['Age'])

    x = m['Age'][:1].values[0]
   
    yf['m'] = m['Age'][:1].values[0]
    yf['f'] = f['Age'][:1].values[0]
    print(yf)
    

if __name__ == "__main__":
    df = fl.load('../ressources/athlete_events.csv')
    YoungestFellah(df, 2004)
    pass
Exemple #2
0
# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    HowManyMedals.py                                   :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: tbrizon <*****@*****.**>            +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2019/12/02 11:17:24 by tbrizon           #+#    #+#              #
#    Updated: 2019/12/02 13:16:04 by tbrizon          ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

import pandas as pd
from FileLoader import FilerLoader
import numpy as np

def HowManyMedals(data, name):
    x = data.loc[(data['Name'] == name)]
    ym = x.groupby(["Year", "Medal"])
    value = ym.size().unstack(fill_value=0)
    value = value.to_dict('index')
    print (value)
    

if __name__ == "__main__":
    data = FilerLoader.load('/private/tmp/tbrizon/bootcamp_python/day04/ressources/athlete_events.csv')
    HowManyMedals(data, 'Kjetil Andr Aamodt')
Exemple #3
0
        il me faut la valeur max de chaque feature pour en faire les xmax de mon histo
        il me faut le nombre de ligne de chaque feature pour en faire le y max 
        """
        
        i = 1
        for feature in features:
            if df[feature].dtypes is object:
                print ('Non numerical value, error')
                exit ()
            i += 1
            x_max = df[feature].max()
            y_max = df[feature].count()
            ndf = df.fillna(0)
            ndf = ndf[ndf[feature] > 0]
            values = ndf[feature].values
            hist, bin = np.histogram(values)
            plt.figure()
            n, bins, patches = plt.hist(x=values, bins=100, color='#0504aa',
                            alpha=0.9, rwidth=0.85)
            plt.title('{} Histogram'.format(feature))
        plt.show()
        
if __name__ == "__main__":
    features = ['Age', 'Height', 'Weight']
    data = FilerLoader.load('/Users/tbrizon/Desktop/tbrizon_42/bootcamp_python/day04/ressources/athlete_events.csv')
    mp = MyPlotLib
    x = HowManyMedalsByCountry(data, 'France')
    #mp.histovie(data, features)
    mp.density(data, features)
    #mp.pairplot(data, features)
    pass