import pandas as pd

Reading CSV and Working with SeriesΒΆ

This notebook explores reading CSV files into Pandas Series (using the squeeze parameter) and performing common Series operations. Topics include: selecting specific columns with usecols, converting between Series and Python types (dict(), list()), sorting by values and index, positional and label-based access, using .get() for safe lookups, descriptive statistics (.describe(), .min(), .max(), .idxmin()), frequency counting with .value_counts(), and mapping values between Series using .map().

Why this matters: Many real-world datasets start as CSV files, and understanding how to efficiently load only the columns you need (reducing memory usage) and how to use Series operations for quick lookups and transformations is essential for building performant data workflows.

pokemon = pd.read_csv("pokemon.csv", usecols=["Pokemon"],squeeze= True)
pokemon
google = pd.read_csv("google_stock_price.csv", squeeze= True)
google
pokemon.head(18)
pokemon.tail(14)
type(pokemon)
dict(google)
list(pokemon)
pokemon.sort_values().head()
pokemon.name = "Pokemon Header"
pokemon.sort_values(ascending= False)
google.sort_values()
google.sort_values(ascending= False, inplace = True)
google.head()
pokemon.sort_index()
pokemon
pokemon[4]
pokemon = pd.read_csv("pokemon.csv", index_col= "Pokemon", squeeze= True)
pokemon
pokemon.get("Hoopa")
pokemon.get(key = "Noibat")
google.describe()
google.min()
google.max()
google.idxmin()
google[11]
pokemon.value_counts()
pokemon.count()
len(pokemon)
pokemon_names = pd.read_csv("pokemon.csv", usecols= ["Pokemon"], squeeze= True)

pokemon_types = pd.read_csv("pokemon.csv", index_col= "Pokemon", squeeze= True)
pokemon_names
pokemon_types
pokemon_names.map(pokemon_types)
pokemon_names = pd.read_csv("pokemon.csv", usecols= ["Pokemon"], squeeze= True)

pokemon_types = pd.read_csv("pokemon.csv", index_col= "Pokemon", squeeze= True).to_dict()
pokemon_types