Add source example files
This commit is contained in:
12
source/pandas/01-pandas-actions/01-dataframe-pivot.py
Normal file
12
source/pandas/01-pandas-actions/01-dataframe-pivot.py
Normal file
@ -0,0 +1,12 @@
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == '__main__':
|
||||
df = pd.DataFrame({
|
||||
'country': ['fra', 'fra', 'fra', 'fra', 'bel', 'bel', 'bel', "bel"],
|
||||
'district': ['north', 'east', 'west', 'south', 'north', 'east', 'west', 'south'],
|
||||
'population': [10_000, 30_000, 50_000, 70_000, 20_000, 40_000, 60_000, 80_000],
|
||||
'extra': ['h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']
|
||||
})
|
||||
df2 = df.pivot_table(values=["population"], index="district", columns="country", aggfunc="count")
|
||||
print(df2.to_string())
|
||||
print(df2.columns)
|
36
source/pandas/01-pandas-files/01-json-demo-communes.py
Normal file
36
source/pandas/01-pandas-files/01-json-demo-communes.py
Normal file
@ -0,0 +1,36 @@
|
||||
import pandas as pd
|
||||
from matplotlib import pyplot as plt
|
||||
import matplotlib
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Configure Pandas to only display floats not in scientific notation
|
||||
pd.options.display.float_format = "{:.2f}".format
|
||||
# Read a list of FR lowest administrative divisions
|
||||
# See france-communes-readme.md for field informations
|
||||
df = pd.read_json("../data/json/france-communes.json")
|
||||
# Get the mean of columns as a new row, and only keep the population column
|
||||
df1 = df.copy()
|
||||
df1.loc["mean"] = df1.mean(skipna=True, numeric_only=True)[["population"]]
|
||||
# Show dataframe
|
||||
print(df1.to_string(max_cols=9))
|
||||
|
||||
# Get only cities in the dept 94
|
||||
df2: pd.DataFrame = df.copy()
|
||||
# Filter rows by using criteria
|
||||
df2 = df2.loc[(df2["departement"] == "94") & (df2["population"] > 0) & (df2["nom"].str.contains(""))]
|
||||
# Sort data by columns
|
||||
df2.sort_values("nom", inplace=True)
|
||||
# Remove columns from the dataframe
|
||||
df2.drop(columns=["chefLieu", "commune"], inplace=True)
|
||||
print(df2.to_string(max_cols=10))
|
||||
|
||||
# Show lines
|
||||
matplotlib.use("QtCairo")
|
||||
plt.rcParams["figure.dpi"] = 96
|
||||
gp = df2.plot.line(x="nom", y="population")
|
||||
plt.show()
|
||||
|
||||
# Get postal codes from line 37237
|
||||
row = df2.loc[37237]
|
||||
print(row["codesPostaux"], type(row["codesPostaux"]))
|
||||
|
10
source/pandas/01-pandas-files/02-database-sqlite.py
Normal file
10
source/pandas/01-pandas-files/02-database-sqlite.py
Normal file
@ -0,0 +1,10 @@
|
||||
import sqlite3
|
||||
import pandas as pd
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
connection = sqlite3.connect("../data/people.sqlite")
|
||||
df = pd.read_sql("SELECT * FROM person", connection)
|
||||
connection.close()
|
||||
|
||||
print(df)
|
11
source/pandas/01-pandas-manual/01-series-demo.py
Normal file
11
source/pandas/01-pandas-manual/01-series-demo.py
Normal file
@ -0,0 +1,11 @@
|
||||
"""Define simple Series objects by hand."""
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Creating a series with coherent value type
|
||||
s1 = pd.Series([1, 3, 7, 9, 13, 15, 19, 21])
|
||||
|
||||
# Get the length of the series
|
||||
print(f"Size of the series: {len(s1)}")
|
||||
# Display the contents of s1
|
||||
print(s1)
|
35
source/pandas/01-pandas-manual/02-dataframe-demo.py
Normal file
35
source/pandas/01-pandas-manual/02-dataframe-demo.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""Define simple DataFrame objects by hand."""
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Creating a series with coherent value type
|
||||
df1 = pd.DataFrame({"age": [25, 45, 65], "prenom": ["Pierre", "Paul", "Jacques"]})
|
||||
|
||||
# Get the column names of the dataframe
|
||||
print("Columns:", df1.columns.tolist())
|
||||
# Get the number of rows in the dataframe
|
||||
print(f"Size of the dataframe in rows: {len(df1)}")
|
||||
# Show the type of the columns
|
||||
print("Data type of columns (autodetected):")
|
||||
type_dict = df1.dtypes.to_dict()
|
||||
for column, dtype in type_dict.items():
|
||||
print(f"{column:<20} : {str(dtype):<20}")
|
||||
print("_" * 80)
|
||||
# Display the contents of the dataframe
|
||||
print(df1)
|
||||
|
||||
# Creating a series with coherent value type
|
||||
df2 = pd.DataFrame([[25, "Pierre"], [45, "Paul"], [65, "Jacques"]])
|
||||
|
||||
# Get the column names of the dataframe
|
||||
print("Columns:", df2.columns.tolist())
|
||||
# Get the number of rows in the dataframe
|
||||
print(f"Size of the dataframe in rows: {len(df2)}")
|
||||
# Show the type of the columns
|
||||
print("Data type of columns (autodetected):")
|
||||
type_dict = df2.dtypes.to_dict()
|
||||
for column, dtype in type_dict.items():
|
||||
print(f"{column:<20} : {str(dtype):<20}")
|
||||
print("_" * 80)
|
||||
# Display the contents of the dataframe
|
||||
print(df2)
|
27
source/pandas/01-pandas-manual/03-dataframe-index-demo.py
Normal file
27
source/pandas/01-pandas-manual/03-dataframe-index-demo.py
Normal 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)
|
21
source/pandas/01-pandas-manual/04-dataframe-load-csv-url.py
Normal file
21
source/pandas/01-pandas-manual/04-dataframe-load-csv-url.py
Normal file
@ -0,0 +1,21 @@
|
||||
"""
|
||||
Read an online CSV file into a DataFrame.
|
||||
|
||||
Since the referenced file contains a datetime column, and by default
|
||||
read_csv does not interpret data from the text file, you have to replace
|
||||
some columns with their conversion as a correct dtype.
|
||||
|
||||
Or better, you can directly tell the read_csv function to interpret
|
||||
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
|
||||
url = "https://media.githubusercontent.com/media/datablist/sample-csv-files/main/files/customers/customers-100.csv"
|
||||
df = pd.read_csv(url, parse_dates=["Subscription Date"])
|
||||
print(df.to_string(max_cols=7))
|
||||
print(df.dtypes)
|
||||
|
||||
# Remplacer une colonne avec une conversionl
|
||||
df["Subscription Date"] = pd.to_datetime(df["Subscription Date"])
|
||||
print(df, df.dtypes)
|
14
source/pandas/01-pandas-manual/05-series-index.py
Normal file
14
source/pandas/01-pandas-manual/05-series-index.py
Normal file
@ -0,0 +1,14 @@
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == '__main__':
|
||||
df = pd.Series([1, 3, 2, 4, 2, 2, 2, 1, 1, 3])
|
||||
# Add an index to the series, that could be used to make a
|
||||
# temporal series.
|
||||
df.index = pd.Series([2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
print(df)
|
||||
|
||||
|
||||
s = pd.Series([2, 5, 2, 6], index=pd.date_range("2023-01-01", "2023-01-10", 4))
|
||||
print(s)
|
||||
dr = pd.date_range("2023-01-01", "2023-01-10", 4)
|
||||
print(dr)
|
22
source/pandas/01-pandas-xls-charts/01-bar-chart.py
Normal file
22
source/pandas/01-pandas-xls-charts/01-bar-chart.py
Normal file
@ -0,0 +1,22 @@
|
||||
import pandas as pd
|
||||
|
||||
|
||||
# Create a Pandas dataframe from the data.
|
||||
df = pd.DataFrame([10, 20, 30, 20, 15, 30, 45])
|
||||
|
||||
# Create a Pandas Excel writer using XlsxWriter as the engine.
|
||||
writer = pd.ExcelWriter('chart-demo.xlsx', engine='xlsxwriter')
|
||||
df.to_excel(writer, sheet_name='Sheet1')
|
||||
|
||||
# Close the Pandas Excel writer and output the Excel file.
|
||||
|
||||
# Get the workbook for the writer
|
||||
workbook: pd.ExcelWriter = writer.book
|
||||
worksheet = writer.sheets['Sheet1']
|
||||
chart = workbook.add_chart({"type": "column"})
|
||||
# Configure the series of the chart from the dataframe data.
|
||||
chart.add_series({'values': '=Sheet1!$B$2:$B$8'})
|
||||
|
||||
# Insert the chart into the worksheet.
|
||||
worksheet.insert_chart('D2', chart)
|
||||
writer.close()
|
BIN
source/pandas/01-pandas-xls-charts/chart-demo.xlsx
Normal file
BIN
source/pandas/01-pandas-xls-charts/chart-demo.xlsx
Normal file
Binary file not shown.
12
source/pandas/02-charts/bar-chart.py
Normal file
12
source/pandas/02-charts/bar-chart.py
Normal file
@ -0,0 +1,12 @@
|
||||
import pandas as pd
|
||||
from matplotlib import pyplot
|
||||
from matplotlib.axes import Axes
|
||||
|
||||
df = pd.read_excel("sample-data-food-sales.xlsx", sheet_name="FoodSales")
|
||||
groups = df.groupby(["Region", "City"])
|
||||
averages = groups.mean(numeric_only=True)
|
||||
|
||||
axis: Axes = averages.plot.bar(rot=0)
|
||||
for p in axis.patches:
|
||||
axis.annotate(f"{p.get_height():.1f}", (p.get_x() + 0.05, p.get_height() + 5), rotation=90)
|
||||
pyplot.show()
|
BIN
source/pandas/02-charts/sample-data-food-sales.xlsx
Normal file
BIN
source/pandas/02-charts/sample-data-food-sales.xlsx
Normal file
Binary file not shown.
8
source/pandas/__init__.py
Normal file
8
source/pandas/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
import pandas as pd
|
||||
from pandas import DataFrame
|
||||
|
||||
|
||||
def get_dataframe(name: str = None) -> DataFrame:
|
||||
"""Load a dataframe from a CSV file in the data folder."""
|
||||
data = pd.read_csv(f"data/{name or 'heights'}.csv")
|
||||
return data
|
24
source/pandas/data/README.md
Normal file
24
source/pandas/data/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Fichiers de données
|
||||
## `sample-data-food-sales.xlsx`
|
||||
|
||||
Complexité : `basse`
|
||||
|
||||
Traitements envisageables :
|
||||
- Gestion des dates
|
||||
- Gestion des feuilles de calcul
|
||||
- Groupements
|
||||
- Tri, Calculs statistiques, Filtres
|
||||
- Tableaux croisés
|
||||
- Affichage de graphiques (facettes)
|
||||
- Calculs simples (ex. quantités + prix unitaire... déjà calculé)
|
||||
|
||||
## `adventure-works-sales.xlsx`
|
||||
|
||||
Complexité : `haute` (nombreuses feuilles)
|
||||
|
||||
Traitements possibles :
|
||||
- Jointures (gauche, droite, externe, interne)
|
||||
- Groupements
|
||||
- Tri, Calculs statistiques, Filtres
|
||||
|
||||
TODO: Charger un CSV avec une colonne de dates (peut-être une conversion depuis un fichier XL)
|
100
source/pandas/data/csv/demo-file.csv
Normal file
100
source/pandas/data/csv/demo-file.csv
Normal file
@ -0,0 +1,100 @@
|
||||
1,"Eldon Base for stackable storage shelf, platinum",Muhammed MacIntyre,3,-213.25,38.94,35,Nunavut,Storage & Organization,0.8
|
||||
2,"1.7 Cubic Foot Compact ""Cube"" Office Refrigerators",Barry French,293,457.81,208.16,68.02,Nunavut,Appliances,0.58
|
||||
3,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Barry French,293,46.71,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
|
||||
4,R380,Clay Rozendal,483,1198.97,195.99,3.99,Nunavut,Telephones and Communication,0.58
|
||||
5,Holmes HEPA Air Purifier,Carlos Soltero,515,30.94,21.78,5.94,Nunavut,Appliances,0.5
|
||||
6,G.E. Longer-Life Indoor Recessed Floodlight Bulbs,Carlos Soltero,515,4.43,6.64,4.95,Nunavut,Office Furnishings,0.37
|
||||
7,"Angle-D Binders with Locking Rings, Label Holders",Carl Jackson,613,-54.04,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
|
||||
8,"SAFCO Mobile Desk Side File, Wire Frame",Carl Jackson,613,127.70,42.76,6.22,Nunavut,Storage & Organization,
|
||||
9,"SAFCO Commercial Wire Shelving, Black",Monica Federle,643,-695.26,138.14,35,Nunavut,Storage & Organization,
|
||||
10,Xerox 198,Dorothy Badders,678,-226.36,4.98,8.33,Nunavut,Paper,0.38
|
||||
11,Xerox 1980,Neola Schneider,807,-166.85,4.28,6.18,Nunavut,Paper,0.4
|
||||
12,Advantus Map Pennant Flags and Round Head Tacks,Neola Schneider,807,-14.33,3.95,2,Nunavut,Rubber Bands,0.53
|
||||
13,Holmes HEPA Air Purifier,Carlos Daly,868,134.72,21.78,5.94,Nunavut,Appliances,0.5
|
||||
14,"DS/HD IBM Formatted Diskettes, 200/Pack - Staples",Carlos Daly,868,114.46,47.98,3.61,Nunavut,Computer Peripherals,0.71
|
||||
15,"Wilson Jones 1"" Hanging DublLock<63> Ring Binders",Claudia Miner,933,-4.72,5.28,2.99,Nunavut,Binders and Binder Accessories,0.37
|
||||
16,Ultra Commercial Grade Dual Valve Door Closer,Neola Schneider,995,782.91,39.89,3.04,Nunavut,Office Furnishings,0.53
|
||||
17,"#10-4 1/8"" x 9 1/2"" Premium Diagonal Seam Envelopes",Allen Rosenblatt,998,93.80,15.74,1.39,Nunavut,Envelopes,0.4
|
||||
18,Hon 4-Shelf Metal Bookcases,Sylvia Foulston,1154,440.72,100.98,26.22,Nunavut,Bookcases,0.6
|
||||
19,"Lesro Sheffield Collection Coffee Table, End Table, Center Table, Corner Table",Sylvia Foulston,1154,-481.04,71.37,69,Nunavut,Tables,0.68
|
||||
20,g520,Jim Radford,1344,-11.68,65.99,5.26,Nunavut,Telephones and Communication,0.59
|
||||
21,LX 788,Jim Radford,1344,313.58,155.99,8.99,Nunavut,Telephones and Communication,0.58
|
||||
22,Avery 52,Carlos Soltero,1412,26.92,3.69,0.5,Nunavut,Labels,0.38
|
||||
23,Plymouth Boxed Rubber Bands by Plymouth,Carlos Soltero,1412,-5.77,4.71,0.7,Nunavut,Rubber Bands,0.8
|
||||
24,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Carl Ludwig,1539,-172.88,15.99,13.18,Nunavut,Binders and Binder Accessories,0.37
|
||||
25,"Maxell 3.5"" DS/HD IBM-Formatted Diskettes, 10/Pack",Carl Ludwig,1539,-144.55,4.89,4.93,Nunavut,Computer Peripherals,0.66
|
||||
26,Newell 335,Don Miller,1540,5.76,2.88,0.7,Nunavut,Pens & Art Supplies,0.56
|
||||
27,SANFORD Liquid Accent<6E> Tank-Style Highlighters,Annie Cyprus,1702,4.90,2.84,0.93,Nunavut,Pens & Art Supplies,0.54
|
||||
28,Canon PC940 Copier,Carl Ludwig,1761,-547.61,449.99,49,Nunavut,Copiers and Fax,0.38
|
||||
29,"Tenex Personal Project File with Scoop Front Design, Black",Carlos Soltero,1792,-5.45,13.48,4.51,Nunavut,Storage & Organization,0.59
|
||||
30,Col-Erase<73> Pencils with Erasers,Grant Carroll,2275,41.67,6.08,1.17,Nunavut,Pens & Art Supplies,0.56
|
||||
31,"Imation 3.5"" DS/HD IBM Formatted Diskettes, 10/Pack",Don Miller,2277,-46.03,5.98,4.38,Nunavut,Computer Peripherals,0.75
|
||||
32,"White Dual Perf Computer Printout Paper, 2700 Sheets, 1 Part, Heavyweight, 20 lbs., 14 7/8 x 11",Don Miller,2277,33.67,40.99,19.99,Nunavut,Paper,0.36
|
||||
33,Self-Adhesive Address Labels for Typewriters by Universal,Alan Barnes,2532,140.01,7.31,0.49,Nunavut,Labels,0.38
|
||||
34,Accessory37,Alan Barnes,2532,-78.96,20.99,2.5,Nunavut,Telephones and Communication,0.81
|
||||
35,Fuji 5.2GB DVD-RAM,Jack Garza,2631,252.66,40.96,1.99,Nunavut,Computer Peripherals,0.55
|
||||
36,Bevis Steel Folding Chairs,Julia West,2757,-1766.01,95.95,74.35,Nunavut,Chairs & Chairmats,0.57
|
||||
37,Avery Binder Labels,Eugene Barchas,2791,-236.27,3.89,7.01,Nunavut,Binders and Binder Accessories,0.37
|
||||
38,Hon Every-Day<61> Chair Series Swivel Task Chairs,Eugene Barchas,2791,80.44,120.98,30,Nunavut,Chairs & Chairmats,0.64
|
||||
39,"IBM Multi-Purpose Copy Paper, 8 1/2 x 11"", Case",Eugene Barchas,2791,118.94,30.98,5.76,Nunavut,Paper,0.4
|
||||
40,Global Troy<6F> Executive Leather Low-Back Tilter,Edward Hooks,2976,3424.22,500.98,26,Nunavut,Chairs & Chairmats,0.6
|
||||
41,XtraLife<EFBFBD> ClearVue<75> Slant-D<> Ring Binders by Cardinal,Brad Eason,3232,-11.83,7.84,4.71,Nunavut,Binders and Binder Accessories,0.35
|
||||
42,Computer Printout Paper with Letter-Trim Perforations,Nicole Hansen,3524,52.35,18.97,9.03,Nunavut,Paper,0.37
|
||||
43,6160,Dorothy Wardle,3908,-180.20,115.99,2.5,Nunavut,Telephones and Communication,0.57
|
||||
44,Avery 49,Aaron Bergman,4132,1.32,2.88,0.5,Nunavut,Labels,0.36
|
||||
45,Hoover Portapower<65> Portable Vacuum,Jim Radford,4612,-375.64,4.48,49,Nunavut,Appliances,0.6
|
||||
46,Timeport L7089,Annie Cyprus,4676,-104.25,125.99,7.69,Nunavut,Telephones and Communication,0.58
|
||||
47,Avery 510,Annie Cyprus,4676,85.96,3.75,0.5,Nunavut,Labels,0.37
|
||||
48,Xerox 1881,Annie Cyprus,4676,-8.38,12.28,6.47,Nunavut,Paper,0.38
|
||||
49,LX 788,Annie Cyprus,4676,1115.69,155.99,8.99,Nunavut,Telephones and Communication,0.58
|
||||
50,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Annie Cyprus,5284,-3.05,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
|
||||
51,"Memorex 4.7GB DVD-RAM, 3/Pack",Clay Rozendal,5316,514.07,31.78,1.99,Nunavut,Computer Peripherals,0.42
|
||||
52,Unpadded Memo Slips,Don Jones,5409,-7.04,3.98,2.97,Nunavut,Paper,0.35
|
||||
53,"Adams Telephone Message Book W/Dividers/Space For Phone Numbers, 5 1/4""X8 1/2"", 300/Messages",Beth Thompson,5506,4.41,5.88,3.04,Nunavut,Paper,0.36
|
||||
54,"Eldon Expressions<6E> Desk Accessory, Wood Pencil Holder, Oak",Frank Price,5569,-0.06,9.65,6.22,Nunavut,Office Furnishings,0.55
|
||||
55,Bell Sonecor JB700 Caller ID,Michelle Lonsdale,5607,-50.33,7.99,5.03,Nunavut,Telephones and Communication,0.6
|
||||
56,Avery Arch Ring Binders,Ann Chong,5894,87.68,58.1,1.49,Nunavut,Binders and Binder Accessories,0.38
|
||||
57,APC 7 Outlet Network SurgeArrest Surge Protector,Ann Chong,5894,-68.22,80.48,4.5,Nunavut,Appliances,0.55
|
||||
58,"Deflect-o RollaMat Studded, Beveled Mat for Medium Pile Carpeting",Joy Bell,5925,-354.90,92.23,39.61,Nunavut,Office Furnishings,0.67
|
||||
59,Accessory4,Joy Bell,5925,-267.01,85.99,0.99,Nunavut,Telephones and Communication,0.85
|
||||
60,Personal Creations<6E> Ink Jet Cards and Labels,Skye Norling,6016,3.63,11.48,5.43,Nunavut,Paper,0.36
|
||||
61,High Speed Automatic Electric Letter Opener,Barry Weirich,6116,-1759.58,1637.53,24.49,Nunavut,"Scissors, Rulers and Trimmers",0.81
|
||||
62,Xerox 1966,Grant Carroll,6182,-116.79,6.48,6.65,Nunavut,Paper,0.36
|
||||
63,Xerox 213,Grant Carroll,6182,-67.28,6.48,7.86,Nunavut,Paper,0.37
|
||||
64,"Boston Electric Pencil Sharpener, Model 1818, Charcoal Black",Adrian Hane,6535,-19.33,28.15,8.99,Nunavut,Pens & Art Supplies,0.57
|
||||
65,Hammermill CopyPlus Copy Paper (20Lb. and 84 Bright),Skye Norling,6884,-61.21,4.98,4.75,Nunavut,Paper,0.36
|
||||
66,"Telephone Message Books with Fax/Mobile Section, 5 1/2"" x 3 3/16""",Skye Norling,6884,119.09,6.35,1.02,Nunavut,Paper,0.39
|
||||
67,Crate-A-Files<65>,Andrew Gjertsen,6916,-141.27,10.9,7.46,Nunavut,Storage & Organization,0.59
|
||||
68,"Angle-D Binders with Locking Rings, Label Holders",Ralph Knight,6980,-77.28,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
|
||||
69,"80 Minute CD-R Spindle, 100/Pack - Staples",Dorothy Wardle,6982,407.44,39.48,1.99,Nunavut,Computer Peripherals,0.54
|
||||
70,"Bush Westfield Collection Bookcases, Dark Cherry Finish, Fully Assembled",Dorothy Wardle,6982,-338.27,100.98,57.38,Nunavut,Bookcases,0.78
|
||||
71,12-1/2 Diameter Round Wall Clock,Dorothy Wardle,6982,52.56,19.98,10.49,Nunavut,Office Furnishings,0.49
|
||||
72,SAFCO Arco Folding Chair,Grant Carroll,7110,1902.24,276.2,24.49,Nunavut,Chairs & Chairmats,
|
||||
73,"#10 White Business Envelopes,4 1/8 x 9 1/2",Barry Weirich,7430,353.20,15.67,1.39,Nunavut,Envelopes,0.38
|
||||
74,3M Office Air Cleaner,Beth Paige,7906,271.78,25.98,5.37,Nunavut,Appliances,0.5
|
||||
75,"Global Leather and Oak Executive Chair, Black",Sylvia Foulston,8391,-268.36,300.98,64.73,Nunavut,Chairs & Chairmats,0.56
|
||||
76,Xerox 1936,Nicole Hansen,8419,70.39,19.98,5.97,Nunavut,Paper,0.38
|
||||
77,Xerox 214,Nicole Hansen,8419,-86.62,6.48,7.03,Nunavut,Paper,0.37
|
||||
78,Carina Double Wide Media Storage Towers in Natural & Black,Nicole Hansen,8833,-846.73,80.98,35,Nunavut,Storage & Organization,0.81
|
||||
79,Staples<EFBFBD> General Use 3-Ring Binders,Beth Paige,8995,8.05,1.88,1.49,Nunavut,Binders and Binder Accessories,0.37
|
||||
80,Xerox 1904,Beth Paige,8995,-78.02,6.48,5.86,Northwest Territories,Paper,0.36
|
||||
81,Luxo Professional Combination Clamp-On Lamps,Beth Paige,8995,737.94,102.3,21.26,Northwest Territories,Office Furnishings,0.59
|
||||
82,Xerox 217,Beth Paige,8995,-191.28,6.48,8.19,Northwest Territories,Paper,0.37
|
||||
83,Revere Boxed Rubber Bands by Revere,Beth Paige,8995,-21.49,1.89,0.76,Northwest Territories,Rubber Bands,0.83
|
||||
84,"Acco Smartsocket<65> Table Surge Protector, 6 Color-Coded Adapter Outlets",Sylvia Foulston,9126,884.08,62.05,3.99,Northwest Territories,Appliances,0.55
|
||||
85,"Tennsco Snap-Together Open Shelving Units, Starter Sets and Add-On Units",Bryan Davis,9127,-329.49,279.48,35,Northwest Territories,Storage & Organization,0.8
|
||||
86,Hon 4070 Series Pagoda<64> Round Back Stacking Chairs,Joy Bell,9509,2825.15,320.98,58.95,Northwest Territories,Chairs & Chairmats,0.57
|
||||
87,Xerox 1887,Joy Bell,9509,2.13,18.97,5.21,Northwest Territories,Paper,0.37
|
||||
88,Xerox 1891,Joy Bell,9509,707.15,48.91,5.81,Northwest Territories,Paper,0.38
|
||||
89,Avery 506,Alan Barnes,9763,75.13,4.13,0.5,Northwest Territories,Labels,0.39
|
||||
90,"Bush Heritage Pine Collection 5-Shelf Bookcase, Albany Pine Finish, *Special Order",Grant Carroll,9927,-270.63,140.98,53.48,Northwest Territories,Bookcases,0.65
|
||||
91,"Lifetime Advantage<67> Folding Chairs, 4/Carton",Grant Carroll,9927,3387.35,218.08,18.06,Northwest Territories,Chairs & Chairmats,0.57
|
||||
92,Microsoft Natural Multimedia Keyboard,Grant Carroll,9927,-82.16,50.98,6.5,Northwest Territories,Computer Peripherals,0.73
|
||||
93,"Staples Wirebound Steno Books, 6"" x 9"", 12/Pack",Delfina Latchford,10022,-3.88,10.14,2.27,Northwest Territories,Paper,0.36
|
||||
94,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Don Jones,10437,-191.22,15.99,13.18,Northwest Territories,Binders and Binder Accessories,0.37
|
||||
95,Bevis Boat-Shaped Conference Table,Doug Bickford,10499,31.21,262.11,62.74,Northwest Territories,Tables,0.75
|
||||
96,"Linden<EFBFBD> 12"" Wall Clock With Oak Frame",Doug Bickford,10535,-44.14,33.98,19.99,Northwest Territories,Office Furnishings,0.55
|
||||
97,Newell 326,Doug Bickford,10535,-0.79,1.76,0.7,Northwest Territories,Pens & Art Supplies,0.56
|
||||
98,Prismacolor Color Pencil Set,Jamie Kunitz,10789,76.42,19.84,4.1,Northwest Territories,Pens & Art Supplies,0.44
|
||||
99,Xerox Blank Computer Paper,Anthony Johnson,10791,93.36,19.98,5.77,Northwest Territories,Paper,0.38
|
||||
100,600 Series Flip,Ralph Knight,10945,4.22,95.99,8.99,Northwest Territories,Telephones and Communication,0.57
|
|
1193
source/pandas/data/csv/heights.csv
Normal file
1193
source/pandas/data/csv/heights.csv
Normal file
File diff suppressed because it is too large
Load Diff
BIN
source/pandas/data/excel/Financial Sample.xlsx
Normal file
BIN
source/pandas/data/excel/Financial Sample.xlsx
Normal file
Binary file not shown.
BIN
source/pandas/data/excel/adventure-works-sales.xlsx
Normal file
BIN
source/pandas/data/excel/adventure-works-sales.xlsx
Normal file
Binary file not shown.
BIN
source/pandas/data/excel/people-accounts.ods
Normal file
BIN
source/pandas/data/excel/people-accounts.ods
Normal file
Binary file not shown.
BIN
source/pandas/data/excel/sample-data-food-sales.xlsx
Normal file
BIN
source/pandas/data/excel/sample-data-food-sales.xlsx
Normal file
Binary file not shown.
BIN
source/pandas/data/excel/superstore-sample.xlsx
Normal file
BIN
source/pandas/data/excel/superstore-sample.xlsx
Normal file
Binary file not shown.
16
source/pandas/data/json/france-communes-readme.md
Normal file
16
source/pandas/data/json/france-communes-readme.md
Normal file
@ -0,0 +1,16 @@
|
||||
Liste de dictionnaires
|
||||
Clés de chaque valeur :
|
||||
- code (str): Code INSEE
|
||||
- nom (str): Nom de commune
|
||||
- typeLiaison (int):
|
||||
- zone (str): "metro" ou "" ou ""
|
||||
- arrondissement (str): numéro d'arrondissement (3 chiffres)
|
||||
- departement (str): numéro de département (2 chiffres)
|
||||
- region (str): numéro de région (2 chiffres)
|
||||
- type (str): ex. "commune-actuelle"
|
||||
- rangChefLieu (int):
|
||||
- siren (str): code SIREN ?
|
||||
- codesPostaux (List[str]): liste de codes postaux
|
||||
- population (int): population de la commune
|
||||
- anciensCodes (List[str]): anciens codes INSEE
|
||||
- chefLieu (str): code du chef-lieu
|
37659
source/pandas/data/json/france-communes.json
Normal file
37659
source/pandas/data/json/france-communes.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
source/pandas/data/json/france-communes.xlsx
Normal file
BIN
source/pandas/data/json/france-communes.xlsx
Normal file
Binary file not shown.
BIN
source/pandas/data/sqlite/people.sqlite
Normal file
BIN
source/pandas/data/sqlite/people.sqlite
Normal file
Binary file not shown.
16
source/pandas/pandas_01_columns.py
Normal file
16
source/pandas/pandas_01_columns.py
Normal file
@ -0,0 +1,16 @@
|
||||
import pandas as pd
|
||||
from pandas import DataFrame
|
||||
|
||||
from source.pandas import get_dataframe
|
||||
|
||||
if __name__ == '__main__':
|
||||
data: DataFrame = get_dataframe()
|
||||
data["height_cm"] = data["height"].map(lambda h: h * 2.54)
|
||||
print(data.groupby("sex").quantile([0.5], numeric_only=True))
|
||||
means = data.groupby("sex").mean(["height", "earn"])
|
||||
means["height_cm"] = means["height"].map(lambda h: h * 2.54)
|
||||
stdevs = data.groupby("sex").std(numeric_only=True)
|
||||
stdevs["height_cm"] = stdevs["height"].map(lambda h: h * 2.54)
|
||||
print(data)
|
||||
print(means)
|
||||
print(stdevs)
|
17
source/pandas/pandas_postgres.py
Normal file
17
source/pandas/pandas_postgres.py
Normal file
@ -0,0 +1,17 @@
|
||||
from sqlalchemy import create_engine
|
||||
import pandas as pd
|
||||
|
||||
pd.options.blipblop = 23
|
||||
# A long string that contains the necessary Postgres login information
|
||||
connection_string = "postgresql://{username}:{password}@{ipaddress}:{port}/{dbname}"
|
||||
|
||||
# Create the connection
|
||||
connection = create_engine(connection_string)
|
||||
|
||||
# Load the data into a DataFrame
|
||||
df = pd.read_sql_query("SELECT * FROM table_name", connection)
|
||||
|
||||
# Close the connection
|
||||
connection.dispose()
|
||||
|
||||
|
Reference in New Issue
Block a user