Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #294 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 54 55 +1
Lines 3121 3250 +129
==========================================
+ Hits 3121 3250 +129 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new dy.infer_schema() function (addressing Issue #232) that generates dataframely schema code from a Polars DataFrame. The function inspects a DataFrame's column types and null counts to produce schema class definitions with appropriate column types and nullable annotations.
Changes:
- New
dataframely/_generate_schema.pymodule implementinginfer_schema()with three return modes (print to stdout, return as string, or return as an executable Schema class), plus supporting helper functions for code generation. - Public API export of
infer_schemaindataframely/__init__.py. - New test file
tests/test_infer_schema.pycovering basic types, nullable detection, datetime types, nested types, invalid identifiers, and round-trip validation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
dataframely/_generate_schema.py |
New module with infer_schema() function and helpers for inferring schema from DataFrame columns, handling type mapping, identifier sanitization, and code generation. |
dataframely/__init__.py |
Exports infer_schema in the public API (import and __all__). |
tests/test_infer_schema.py |
Tests for string output mode across all supported types and round-trip validation via schema return mode. |
|
hello @borchero, does this implementation is close to something mergable ? |
Fixes: #232
dy.infer_schema()function to generate dataframely schema code from a Polars DataFramereturn_typeparameter:None(default): prints schema to stdout for quick exploration"string": returns schema code as a string"schema": returns an actual Schema class for direct useThis add the
Not supported (potential future enhancements)