145 KiB
145 KiB
None
<html lang="en">
<head>
gitea_input3018089681
</head>
</html>
In [2]:
import polars as ps
pokémon = ps.read_csv("./pokémon/Pokemon.csv")
pokémon
Out[2]:
In [3]:
pokémon.sort(ps.col("HP")).tail(1)
Out[3]:
In [4]:
from polars import col
pokémon.select(ps.col("Type 2").fill_null(ps.col("Type 1")))
pnn = pokémon.with_columns([
ps.when(col("Type 2").is_null()).then(col("Type 1")).otherwise(col("Type 2")).alias("Type 2")
])
pnn
Out[4]:
In [5]:
gen1 = pnn.filter(col("Generation") == 1)
gen1
Out[5]:
In [6]:
no_megas = pnn.filter(~col("Name").str.contains("Mega "))
no_megas
Out[6]:
In [24]:
from plotnine import ggplot, aes, geom_histogram, labs
(
ggplot(no_megas.to_pandas())
+ aes(x="Attack")
+ geom_histogram(bins=(200/25))
+ labs(title="Distribution of attack stat for all Pokémon", y="Amount of Pokémon")
)
In [28]:
only_fairy = pnn.filter(col("Type 1").str.contains("Fairy") | col("Type 2").str.contains("Fairy"))
(
ggplot(only_fairy.to_pandas())
+ aes(x="Generation")
+ geom_histogram(bins=(6), color='#EF9FEF', fill='#EF6FEF')
+ labs(title="Amount of fairy Pokémon in each generation", y="Amount of Pokémon")
)