Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
09d2ddf
Add categorical support for narwhals-supported dataframe backends
maxzw Jun 24, 2026
a208c74
bump minimum narwhals to 2.11
maxzw Jun 24, 2026
9ba05ee
Remove filterwarnings decorator
maxzw Jun 24, 2026
fb885f0
Simplify flow
maxzw Jun 24, 2026
243e6ad
Add comment on pandas-numpy zero-copy path
maxzw Jun 24, 2026
ba5df42
Clarify comment
maxzw Jun 24, 2026
2054aeb
Fix issue with different categories in train/valid
maxzw Jun 24, 2026
9d35391
Simplify comment
maxzw Jun 24, 2026
6442351
Add categorical tests for pyarrow
maxzw Jun 27, 2026
ef34647
Use fixture to isolate per-test categorical string cache
maxzw Jun 27, 2026
766393b
Simplify polars tests by using random method for category scope
maxzw Jun 27, 2026
98791af
Support unobserved categories in Enum dtype
maxzw Jun 27, 2026
ee75ef9
Skip tests for polars < 1.32
maxzw Jun 27, 2026
e71dfe9
Lint
maxzw Jun 27, 2026
48a3b06
Also run polars tests for python 3.10
maxzw Jun 27, 2026
b73b148
More simplifications
maxzw Jun 27, 2026
84a09b7
Update documentation
maxzw Jun 28, 2026
e6e5214
Add generic dtype validation for Narwhals supported backends
maxzw Jun 29, 2026
afe37d8
Shorten PeriodDtype test case
maxzw Jun 30, 2026
0717bc9
Add SparseDtype test case
maxzw Jun 30, 2026
a4e7e09
Bump Narwhals to 2.23.0
maxzw Jul 1, 2026
cc434ec
Simplify dtype validation
maxzw Jul 2, 2026
69141e5
Move test_narwhals_dtype_validation_for_pandas to test_pandas.py
maxzw Jul 4, 2026
c296814
Rename valid/invalid to supported/unsupported
maxzw Jul 4, 2026
84c978a
Revert to Narwhals bump v2.11.0, and add workarounds for edge cases
maxzw Jul 4, 2026
a416b17
Merge branch 'master' into feat/narwhals-generic-categorical-support
maxzw Jul 9, 2026
817d82c
Merge branch 'main' into feat/narwhals-generic-categorical-support
maxzw Jul 12, 2026
e525749
Simplify tests
maxzw Jul 12, 2026
9c5f854
Add comment
maxzw Jul 12, 2026
0e8d559
Simplify changes documentation
maxzw Jul 12, 2026
975fa74
Remove unnecessary cast to set
maxzw Jul 12, 2026
1c11624
Fix leakage for global polars categoricals
maxzw Jul 13, 2026
de94391
Address minor comments
maxzw Jul 14, 2026
a1e5464
Use is_pandas instead of is_pandas_like
maxzw Jul 16, 2026
41232a3
Merge branch 'main' into feat/narwhals-generic-categorical-support
maxzw Jul 17, 2026
626df36
Merge main
maxzw Jul 18, 2026
cc47702
Batch cat to code conversions
maxzw Jul 18, 2026
044341e
Use column selector and remove recast
maxzw Jul 19, 2026
bd33be7
Correctly handle null values in categorical columns
maxzw Jul 21, 2026
529f02b
Parametrize pandas for null/nan test cases
maxzw Jul 21, 2026
1d2f5c1
Simplify extracting pandas_categorical with minimal relative overhead
maxzw Jul 21, 2026
8e3bd2a
Handle ordered/unordered categories uniformly across dataframe backends
maxzw Jul 22, 2026
a69745a
Merge branch 'main' into feat/narwhals-generic-categorical-support
maxzw Jul 22, 2026
bf3815b
Use proper typing of data in _data_from_narwhals
maxzw Jul 22, 2026
21ba21d
Merge main
maxzw Jul 27, 2026
1dd38e9
Comments
maxzw Jul 27, 2026
521bbe4
Sort with expression
maxzw Jul 27, 2026
fc10ed7
Align tests
maxzw Jul 27, 2026
3df5ae1
Reorder _check_for_bad_narwhals_dtypes - put pandas at the top
maxzw Aug 5, 2026
f91a636
Simplify narwhals version
maxzw Aug 5, 2026
d7e94d7
Merge branch 'main' into feat/narwhals-generic-categorical-support
maxzw Aug 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/conda-envs/ci-core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cffi>=1.16
dask>=2025.4.0
joblib>=1.3.2
matplotlib-base>=3.7.3
narwhals>=1.15
narwhals>=2.11
Comment thread
maxzw marked this conversation as resolved.
numpy>=1.24.4
pandas>2.0
polars>=1.0.0
Expand Down
2 changes: 1 addition & 1 deletion .ci/pip-envs/requirements-oldest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# see https://devguide.python.org/versions/
#
cffi==1.15.1
narwhals==1.15.0
narwhals==2.11.0
numpy==1.22.4
pandas==1.3.4
polars==1.0.0
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ repos:
verbose: true
additional_dependencies:
- matplotlib>=3.9.1
- narwhals>=1.15
- narwhals>=2.11
- pandas>=2.0
- scikit-learn>=1.5.2
- repo: https://github.com/zizmorcore/zizmor-pre-commit
Expand Down
4 changes: 2 additions & 2 deletions docs/Advanced-Topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Categorical Feature Support
- Use ``categorical_feature`` to specify the categorical features.
Refer to the parameter ``categorical_feature`` in `Parameters <./Parameters.rst#categorical_feature>`__.

- Categorical features will be cast to ``int32`` (integer codes will be extracted from pandas categoricals in the Python-package) so they must be encoded as non-negative integers (negative values will be treated as missing)
- Categorical features will be cast to ``int32`` (integer codes will be extracted from categorical or enum dtypes in the Python-package) so they must be encoded as non-negative integers (negative values will be treated as missing)
less than ``Int32.MaxValue`` (2147483647).
It is best to use a contiguous range of integers started from zero.
Floating point numbers in categorical features will be rounded towards 0.

- When using ``pandas.DataFrame`` inputs with columns of dtype ``category``, LightGBM will
- For dataframe inputs with categorical or enum dtypes, LightGBM will
align categories to those observed during training before converting them to integer values.
This ensures consistent encoding between training and prediction without additional preprocessing.

Expand Down
2 changes: 1 addition & 1 deletion docs/Parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ Dataset Parameters

- add a prefix ``name:`` for column name, e.g. ``categorical_feature=name:c1,c2,c3`` means c1, c2 and c3 are categorical features

- **Note**: all values will be cast to ``int32`` (integer codes will be extracted from pandas categoricals in the Python-package)
- **Note**: all values will be cast to ``int32`` (integer codes will be extracted from categorical or enum dtypes in the Python-package)

- **Note**: index starts from ``0`` and it doesn't count the label column when passing type is ``int``

Expand Down
2 changes: 1 addition & 1 deletion include/LightGBM/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ struct Config {
// desc = used to specify categorical features
// desc = use number for index, e.g. ``categorical_feature=0,1,2`` means column\_0, column\_1 and column\_2 are categorical features
// desc = add a prefix ``name:`` for column name, e.g. ``categorical_feature=name:c1,c2,c3`` means c1, c2 and c3 are categorical features
// desc = **Note**: all values will be cast to ``int32`` (integer codes will be extracted from pandas categoricals in the Python-package)
// desc = **Note**: all values will be cast to ``int32`` (integer codes will be extracted from categorical or enum dtypes in the Python-package)
// desc = **Note**: index starts from ``0`` and it doesn't count the label column when passing type is ``int``
// desc = **Note**: all values should be less than ``Int32.MaxValue`` (2147483647)
// desc = **Note**: using large values could be memory consuming. Tree decision rule works best when categorical features are presented by consecutive integers starting from zero
Expand Down
44 changes: 22 additions & 22 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "lightgbm"
platforms = ["linux-64", "linux-aarch64", "osx-64", "osx-arm64", "win-64"]

[dependencies]
narwhals = ">=1.15"
narwhals = ">=2.11"
numpy = ">=1.21.3"
pip = "*"
python = ">=3.10"
Expand All @@ -15,7 +15,7 @@ scipy = "*"
cffi = "1.15.*"
joblib = "1.3.*"
matplotlib-base = "3.7.*"
narwhals = "1.15.*"
narwhals = "2.11.*"
numpy = "1.22.*"
pandas = "1.3.*"
polars = "1.0.*"
Expand Down
Loading
Loading