<jupyter_start><jupyter_text>Race-Bar Chart: Completed 2021-05-25 Mario Kart World Records https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-05-25/readme.md   Learning Links https://towardsdatascience.com/creating-bar-chart-race-animation-with-python-cdb01144074e<jupyter_code>import pandas as pd 

df= pd.read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-05-25/records.csv')
df.head()
# Skipping Cleaning
df['date']= pd.to_datetime(df['date']) 
df.groupby([df['date'].dt.year, df['date'].dt.month,df['player']]).agg({'time':min}).unstack()
a=df.groupby([df['date'].dt.year,'player'])['time'].min().unstack()
a.head()
import bar_chart_race as bcr
bcr.bar_chart_race(df=a, filename='a2.mp4')
bcr.bar_chart_race(df = a, 
                   n_bars = 6, 
                   sort='asc',
                   title='Premier League Clubs Points Since 1992',
                   filename = 'pl_clubs.mp4')
def bar_race(df, title):

    bcr.bar_chart_race(
        df=a,
        filename=title+'.mp4',
        orientation='h',
        sort='asc',
        n_bars=6,
        fixed_order=False,
        fixed_max=False,
        steps_per_period=1,
        period_label={'x': .99, 'y': .25, 'ha': 'right', 'va': 'center'},
        period_fmt= None,
        # period_summary_func=lambda v, r: {'x': .99, 'y': .18,
        #                                   's': f'Fastest times: {v.nsmallest(6).min():,.0f}',
        #                                   'ha': 'right', 'size': 8, 'family': 'Courier New'},
        perpendicular_bar_func='median',
        period_length=800,
        figsize=(5, 8),
        dpi=144,
        cmap='dark12',
        title=title,
        title_size='',
        bar_label_size=7,
        tick_label_size=7,
        shared_fontdict={'family' : 'Helvetica', 'color' : '.1'},
        scale='linear',
        writer='ffmpeg',
        fig=None,
        bar_kwargs={'alpha': .7},
        filter_column_colors=True)  
    pass 
bar_race(a,'Fastest time by player (Any Type)')
b= df[df["type"]=="Three Lap"].groupby(['date','player'])['time'].min().unstack()
bar_race(b,'Fastest time by player (Three Laps)')
c= df[df["type"]=="One Lap"].groupby(['date','player'])['time'].min().unstack()
bar_race(c,'Fastest time by player (One Lap)')<jupyter_output>d:\Users\DComputer\Desktop\learning\Streamlined EDA and ML\project_env\lib\site-packages\matplotlib\backends\backend_agg.py:238: RuntimeWarning: Glyph 127 missing from current font.
  font.set_text(s, 0.0, flags=flags)
d:\Users\DComputer\Desktop\learning\Streamlined EDA and ML\project_env\lib\site-packages\matplotlib\backends\backend_agg.py:238: RuntimeWarning: Glyph 128 missing from current font.
  font.set_text(s, 0.0, flags=flags)
d:\Users\DComputer\Desktop\learning\Streamlined EDA and ML\project_env\lib\site-packages\matplotlib\backends\backend_agg.py:238: RuntimeWarning: Glyph 129 missing from current font.
  font.set_text(s, 0.0, flags=flags)
d:\Users\DComputer\Desktop\learning\Streamlined EDA and ML\project_env\lib\site-packages\matplotlib\backends\backend_agg.py:238: RuntimeWarning: Glyph 130 missing from current font.
  font.set_text(s, 0.0, flags=flags)
d:\Users\DComputer\Desktop\learning\Streamlined EDA and ML\project_env\lib\site-packages\matplotlib\backends\backend_agg.py:[...]
{'fraction_non_alphanumeric': 0.16260895701833483, 'fraction_numerical': 0.032461677186654644, 'mean_word_length': 3.425531914893617, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '497354', 'license': 'MIT', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1146, 'n_words': 189, 'path': 'Tidy-Tuesday-Insights/mario.ipynb', 'repo_name': 'shawnd29/Tidy-Tuesday', 'size': '3327'}