Debian Codegraph @

tests/data/unit_tests/completions/README.md

raw
1
2
3 The completions were generated from this database:
4
5 ```python
6 from sklearn.datasets import load_iris
7 import pandas as pd
8 import duckdb
9
10 # Load the iris dataset
11 iris = load_iris()
12 iris_df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
13 iris_df["target"] = iris.target
14 iris_df["species"] = pd.Categorical.from_codes(iris.target, iris.target_names)
15
16 # Connect to DuckDB (this will create a new database if it doesn't exist)
17 con = duckdb.connect("iris.db")
18
19 # Create and insert data into the table
20 con.execute("""
21 CREATE TABLE IF NOT EXISTS iris (
22 sepal_length FLOAT,
23 sepal_width FLOAT,
24 petal_length FLOAT,
25 petal_width FLOAT,
26 target INTEGER,
27 species VARCHAR
28 )
29 """)
30
31 # Insert the data
32 con.execute("INSERT INTO iris SELECT * FROM iris_df")
33
34 # Verify the data (optional)
35 result = con.execute("SELECT * FROM iris LIMIT 5").fetchall()
36 print("First 5 rows:", result)
37
38 # Close the connection
39 con.close()
40 ```
41 Essentially the database was created and then sunk the data in the completions
42 to json using `dataclasses.asdict` and `json.dumps`. Proceeded with some manual
43 deletion to make the file smaller.
44