-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fuzzy matching completions (#671)
* feat: fuzzy matching * chore: updated changelog * feat(completions): conditional fuzzy match * (pr) review suggestions * chore: updated snapshots to py3.10 * fix: add updated snapshot for 3.12 --------- Co-authored-by: Ted Conbeer <[email protected]>
- Loading branch information
Showing
6 changed files
with
996 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
The completions were generated from this database: | ||
|
||
```python | ||
from sklearn.datasets import load_iris | ||
import pandas as pd | ||
import duckdb | ||
|
||
# Load the iris dataset | ||
iris = load_iris() | ||
iris_df = pd.DataFrame(data=iris.data, columns=iris.feature_names) | ||
iris_df["target"] = iris.target | ||
iris_df["species"] = pd.Categorical.from_codes(iris.target, iris.target_names) | ||
|
||
# Connect to DuckDB (this will create a new database if it doesn't exist) | ||
con = duckdb.connect("iris.db") | ||
|
||
# Create and insert data into the table | ||
con.execute(""" | ||
CREATE TABLE IF NOT EXISTS iris ( | ||
sepal_length FLOAT, | ||
sepal_width FLOAT, | ||
petal_length FLOAT, | ||
petal_width FLOAT, | ||
target INTEGER, | ||
species VARCHAR | ||
) | ||
""") | ||
|
||
# Insert the data | ||
con.execute("INSERT INTO iris SELECT * FROM iris_df") | ||
|
||
# Verify the data (optional) | ||
result = con.execute("SELECT * FROM iris LIMIT 5").fetchall() | ||
print("First 5 rows:", result) | ||
|
||
# Close the connection | ||
con.close() | ||
``` | ||
Essentially the database was created and then sunk the data in the completions | ||
to json using `dataclasses.asdict` and `json.dumps`. Proceeded with some manual | ||
deletion to make the file smaller. | ||
|
Oops, something went wrong.