import%20marimo%0A%0A__generated_with%20%3D%20%220.13.15%22%0Aapp%20%3D%20marimo.App()%0A%0Awith%20app.setup%3A%0A%20%20%20%20from%20pathlib%20import%20Path%0A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20plotly.graph_objects%20as%20go%0A%20%20%20%20import%20polars%20as%20pl%0A%0A%20%20%20%20path%20%3D%20Path(__file__).parent%0A%0A%20%20%20%20u%20%3D%20pl.read_csv(str(path%20%2F%20%22public%22%20%2F%20%22us.csv%22))%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%23%20The%20Elvis%20effect%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Filter%20for%20Elvis%20and%20Male%20gender%0A%0A%20%20%20%20_f%20%3D%20u.filter((pl.col(%22Name%22)%20%3D%3D%20%22Elvis%22)%20%26%20(pl.col(%22Gender%22)%20%3D%3D%20%22M%22))%0A%0A%20%20%20%20%23%20Sort%20by%20year%20for%20plotting%0A%20%20%20%20_f%20%3D%20_f.sort(%22year%22)%0A%0A%20%20%20%20%23%20Create%20a%20plot%0A%20%20%20%20_fig%20%3D%20go.Figure()%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_f%5B%22year%22%5D.to_list()%2C%20y%3D_f%5B%22n%22%5D.to_list()%2C%20mode%3D%22lines%22))%0A%20%20%20%20_fig.update_layout(title%3D%22%23%20Boys%20named%20Elvis%22%2C%20xaxis_title%3D%22Year%22%2C%20yaxis_title%3D%22Count%22)%0A%20%20%20%20_fig.show()%0A%0A%20%20%20%20%23%20Show%20top%2010%20years%0A%20%20%20%20print(%22Top%2010%20years%20for%20Elvis%3A%22)%0A%20%20%20%20print(_f.sort(%22n%22%2C%20descending%3DTrue).head(10))%0A%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Filter%20for%20Elvis%20and%20Female%20gender%0A%20%20%20%20_f_1%20%3D%20u.filter((pl.col(%22Name%22)%20%3D%3D%20%22Elvis%22)%20%26%20(pl.col(%22Gender%22)%20%3D%3D%20%22F%22))%0A%0A%20%20%20%20%23%20Sort%20by%20year%20for%20plotting%0A%20%20%20%20_f_1%20%3D%20_f_1.sort(%22year%22)%0A%0A%20%20%20%20%23%20Create%20a%20plot%0A%20%20%20%20_fig%20%3D%20go.Figure()%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_f_1%5B%22year%22%5D.to_list()%2C%20y%3D_f_1%5B%22n%22%5D.to_list()%2C%20mode%3D%22lines%22))%0A%20%20%20%20_fig.update_layout(title%3D%22%23%20Girls%20named%20Elvis%22%2C%20xaxis_title%3D%22Year%22%2C%20yaxis_title%3D%22Count%22)%0A%20%20%20%20_fig.show()%0A%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Filter%20for%20Nikita%20and%20Female%20gender%0A%20%20%20%20_f_2%20%3D%20u.filter((pl.col(%22Name%22)%20%3D%3D%20%22Nikita%22)%20%26%20(pl.col(%22Gender%22)%20%3D%3D%20%22F%22))%0A%0A%20%20%20%20%23%20Sort%20by%20year%20for%20plotting%0A%20%20%20%20_f_2%20%3D%20_f_2.sort(%22year%22)%0A%0A%20%20%20%20%23%20Polars%20doesn't%20have%20a%20built-in%20plot%20method%2C%20so%20we'll%20use%20plotly%0A%20%20%20%20%23%20import%20plotly.graph_objects%20as%20go%0A%0A%20%20%20%20%23%20Create%20a%20plot%0A%20%20%20%20_fig%20%3D%20go.Figure()%0A%20%20%20%20_fig.add_trace(go.Scatter(x%3D_f_2%5B%22year%22%5D.to_list()%2C%20y%3D_f_2%5B%22n%22%5D.to_list()%2C%20mode%3D%22lines%22))%0A%20%20%20%20_fig.update_layout(title%3D%22%23%20Girls%20named%20Nikita%22%2C%20xaxis_title%3D%22Year%22%2C%20yaxis_title%3D%22Count%22)%0A%20%20%20%20_fig.show()%0A%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Group%20by%20Name%20and%20Gender%20and%20sum%20the%20counts%0A%20%20%20%20_a%20%3D%20u.group_by(%5B%22Name%22%2C%20%22Gender%22%5D).agg(pl.sum(%22n%22).alias(%22total%22))%0A%0A%20%20%20%20%23%20Sort%20by%20total%20count%0A%20%20%20%20_a%20%3D%20_a.sort(%22total%22)%0A%0A%20%20%20%20%23%20Display%20the%20results%0A%20%20%20%20print(%22Names%20sorted%20by%20total%20count%3A%22)%0A%20%20%20%20print(_a.head(20))%0A%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
48e4c951e60f4db373a005eba8f07ebae31603be5e4f3357762c9d41c3b9bb0c