Add source example files

This commit is contained in:
2025-07-12 18:43:56 +02:00
parent 11d6846f49
commit d0bcfcf8f1
62 changed files with 40101 additions and 161 deletions

View File

@ -0,0 +1,27 @@
"""
Create a DataFrame and use indexes to
"""
import pandas as pd
# Create a dataframe and associate an index to it
df = pd.DataFrame(
data={"name": ["Mac", "Ann", "Rob"], "age": [33, 44, 55]},
index=["u1", "u2", "u3"] # as many values as rows
)
# Show normal DataFrame
print(df)
# Access one row using an index value
print(df.loc["u1"])
# Access the same row using a numerical index
print(df.iloc[0])
# Get a DataFrame with a selection of lines
# To extract this, the selection of lines **must** be a list and not a tuple;
# the tuple is used to select or slice in the other axis.
print(df.loc[["u1", "u3", "u2"]])
# Show the index0
print(df.index)