chalkpy 2.96.9__py3-none-any.whl → 2.97.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
chalk/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.96.9"
1
+ __version__ = "2.97.0"
@@ -566,7 +566,7 @@ class LazyFramePlaceholder:
566
566
  columns=columns,
567
567
  )
568
568
 
569
- def select(self, *columns: str, strict: bool = True) -> "LazyFramePlaceholder":
569
+ def select(self, *columns: str | Underscore, strict: bool = True) -> "LazyFramePlaceholder":
570
570
  """Select existing columns by name.
571
571
 
572
572
  Parameters
@@ -595,7 +595,7 @@ class LazyFramePlaceholder:
595
595
  strict=strict,
596
596
  )
597
597
 
598
- def drop(self, *columns: str, strict: bool = True) -> LazyFramePlaceholder:
598
+ def drop(self, *columns: str | Underscore, strict: bool = True) -> LazyFramePlaceholder:
599
599
  """Drop specified columns from the DataFrame.
600
600
 
601
601
  Parameters
@@ -624,7 +624,7 @@ class LazyFramePlaceholder:
624
624
  strict=strict,
625
625
  )
626
626
 
627
- def explode(self, column: str) -> "LazyFramePlaceholder":
627
+ def explode(self, column: str | Underscore) -> "LazyFramePlaceholder":
628
628
  """Explode a list or array column into multiple rows.
629
629
 
630
630
  Each element in the list becomes a separate row, with other column
@@ -654,7 +654,10 @@ class LazyFramePlaceholder:
654
654
  def join(
655
655
  self,
656
656
  other: "LazyFramePlaceholder",
657
- on: dict[str, str] | typing.Sequence[str],
657
+ *,
658
+ on: typing.Mapping[str | Underscore, str | Underscore] | typing.Sequence[str | Underscore] | None = None,
659
+ left_on: typing.Sequence[str | Underscore] | None = None,
660
+ right_on: typing.Sequence[str | Underscore] | None = None,
658
661
  how: str = "inner",
659
662
  right_suffix: str | None = None,
660
663
  ) -> "LazyFramePlaceholder":
@@ -665,11 +668,29 @@ class LazyFramePlaceholder:
665
668
  other
666
669
  Right-hand ``DataFrame``.
667
670
  on
668
- Column names or mapping of left->right join keys.
671
+ Join keys. Can be specified in multiple ways:
672
+ - A sequence of column names (same names on both sides): ``on=["col1", "col2"]``
673
+ - A mapping of left->right column names: ``on={"left_col": "right_col"}``
674
+ - If None, must specify ``left_on`` and ``right_on`` separately.
675
+ left_on
676
+ Column names for left DataFrame join keys. Only used when ``on`` is None.
677
+ Must be paired with ``right_on``.
678
+ right_on
679
+ Column names for right DataFrame join keys. Only used when ``on`` is None.
680
+ Must be paired with ``left_on``.
669
681
  how
670
- Join type (e.g. ``"inner"`` or ``"left"``).
682
+ Join type. Supported values:
683
+ - ``"inner"``: Keep only rows that match in both DataFrames (default)
684
+ - ``"left"``: Keep all rows from left DataFrame
685
+ - ``"right"``: Keep all rows from right DataFrame
686
+ - ``"outer"`` or ``"full"``: Keep all rows from both DataFrames
687
+ - ``"semi"``: Return rows from left that have matches in right (no right columns)
688
+ - ``"anti"``: Return rows from left that have no matches in right
689
+ - ``"cross"``: Cartesian product (do not pass in ``on``)
671
690
  right_suffix
672
691
  Optional suffix applied to right-hand columns when names collide.
692
+ For example, if both DataFrames have a column ``"value"`` and ``right_suffix="_right"``,
693
+ the result will have ``"value"`` and ``"value_right"``.
673
694
 
674
695
  Returns
675
696
  -------
@@ -681,18 +702,22 @@ class LazyFramePlaceholder:
681
702
  function_name="join",
682
703
  other=other,
683
704
  on=on,
705
+ left_on=left_on,
706
+ right_on=right_on,
684
707
  how=how,
685
708
  right_suffix=right_suffix,
686
709
  )
687
710
 
688
711
  def join_asof(
689
712
  self,
690
- other: LazyFramePlaceholder,
691
- on: str,
713
+ other: "LazyFramePlaceholder",
692
714
  *,
693
- right_on: str | None = None,
694
- by: list[str] | None = None,
695
- right_by: list[str] | None = None,
715
+ on: str | Underscore | None = None,
716
+ left_on: str | Underscore | None = None,
717
+ right_on: str | Underscore | None = None,
718
+ by: typing.Mapping[str | Underscore, str | Underscore] | typing.Sequence[str | Underscore] | None = None,
719
+ left_by: typing.Sequence[str | Underscore] | None = None,
720
+ right_by: typing.Sequence[str | Underscore] | None = None,
696
721
  strategy: typing.Literal["forward", "backward"] = "backward",
697
722
  right_suffix: str | None = None,
698
723
  coalesce: bool = True,
@@ -703,24 +728,41 @@ class LazyFramePlaceholder:
703
728
  it matches on the nearest key from the right DataFrame. This is commonly used
704
729
  for time-series data where you want to join with the most recent observation.
705
730
 
706
- **Important**: Both DataFrames must be sorted by the ``on`` column before calling
707
- this method. Use ``.order_by(on)`` to sort if needed.
731
+ **Important**: Both DataFrames must be sorted by the ``on`` (or ``left_on/right_on``)
732
+ column before calling this method. Use ``.order_by(on)`` to sort if needed.
708
733
 
709
734
  Parameters
710
735
  ----------
711
736
  other
712
737
  Right-hand DataFrame to join with.
713
738
  on
714
- Column name in the left DataFrame to join on (must be sorted).
739
+ Column name to use as the as-of join key (must be sorted).
740
+ This column is used for both left and right DataFrames.
741
+ The join finds the nearest match according to the ``strategy``.
742
+ Either ``on`` or both ``left_on`` and ``right_on`` must be specified.
743
+ left_on
744
+ Column name in left DataFrame for the as-of join key. Only used when ``on``
745
+ is None. Must be paired with ``right_on``.
715
746
  right_on
716
- Column name in the right DataFrame to join on. If None, uses ``on``.
747
+ Column name in right DataFrame for the as-of join key. Can be used with ``on``
748
+ (to specify a different right column name) or with ``left_on`` (when ``on`` is None).
717
749
  by
718
- Additional exact-match columns for left DataFrame (optional).
750
+ Additional exact-match columns (optional). These columns must match exactly
751
+ before performing the as-of match on the ``on`` column. Can be specified as:
752
+ - A sequence of column names (same names on both sides): ``by=["col1", "col2"]``
753
+ - A mapping of left->right column names: ``by={"left_col": "right_col"}``
754
+ - If None, can specify ``left_by`` and ``right_by`` separately.
755
+ left_by
756
+ Column names in left DataFrame for exact-match conditions. Only used when
757
+ ``by`` is None. Must be paired with ``right_by``.
719
758
  right_by
720
- Additional exact-match columns for right DataFrame. If None, uses ``by``.
759
+ Column names in right DataFrame for exact-match conditions. Only used when
760
+ ``by`` is None. Must be paired with ``left_by``.
721
761
  strategy
722
- Join strategy - "backward" (default) matches with the most recent past value,
723
- "forward" matches with the nearest future value. Can also pass AsOfJoinStrategy enum.
762
+ Join strategy controlling which match to select:
763
+ - ``"backward"`` (default): Match with the most recent past value
764
+ - ``"forward"``: Match with the nearest future value
765
+ Can also pass ``AsOfJoinStrategy.BACKWARD`` or ``AsOfJoinStrategy.FORWARD``.
724
766
  right_suffix
725
767
  Suffix to add to overlapping column names from the right DataFrame.
726
768
  coalesce
@@ -737,8 +779,10 @@ class LazyFramePlaceholder:
737
779
  function_name="join_asof",
738
780
  other=other,
739
781
  on=on,
782
+ left_on=left_on,
740
783
  right_on=right_on,
741
784
  by=by,
785
+ left_by=left_by,
742
786
  right_by=right_by,
743
787
  strategy=strategy,
744
788
  right_suffix=right_suffix,
@@ -748,13 +792,13 @@ class LazyFramePlaceholder:
748
792
  # # Window is not yet supported in LazyFramePlaceholder:
749
793
  # def window(
750
794
  # self,
751
- # by: typing.Sequence[str],
752
- # order_by: typing.Sequence[str | tuple[str, str]],
795
+ # by: typing.Sequence[str | Underscore],
796
+ # order_by: typing.Sequence[str | Underscore | tuple[str | Underscore, str]],
753
797
  # *expressions: WindowExpr,
754
798
  # ) -> LazyFramePlaceholder:
755
799
  # ...
756
800
 
757
- def agg(self, by: typing.Sequence[str], *aggregations: Underscore) -> "LazyFramePlaceholder":
801
+ def agg(self, by: typing.Sequence[str | Underscore], *aggregations: Underscore) -> "LazyFramePlaceholder":
758
802
  """Group by columns and apply aggregation expressions.
759
803
 
760
804
  Parameters
@@ -785,7 +829,7 @@ class LazyFramePlaceholder:
785
829
  args=(by, *aggregations),
786
830
  )
787
831
 
788
- def distinct_on(self, *columns: str) -> "LazyFramePlaceholder":
832
+ def distinct_on(self, *columns: str | Underscore) -> "LazyFramePlaceholder":
789
833
  """Remove duplicate rows based on specified columns.
790
834
 
791
835
  For rows with identical values in the specified columns, only one
@@ -813,7 +857,7 @@ class LazyFramePlaceholder:
813
857
  args=columns,
814
858
  )
815
859
 
816
- def order_by(self, *columns: str | tuple[str, str]) -> LazyFramePlaceholder:
860
+ def order_by(self, *columns: str | Underscore | tuple[str | Underscore, str]) -> LazyFramePlaceholder:
817
861
  """Sort the DataFrame by one or more columns.
818
862
 
819
863
  Parameters
@@ -889,7 +933,7 @@ class LazyFramePlaceholder:
889
933
  connector_id=connector_id,
890
934
  )
891
935
 
892
- def rename(self, new_names: dict[str, str]) -> LazyFramePlaceholder:
936
+ def rename(self, new_names: typing.Mapping[str | Underscore, str]) -> LazyFramePlaceholder:
893
937
  """Rename columns in the DataFrame.
894
938
 
895
939
  Parameters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chalkpy
3
- Version: 2.96.9
3
+ Version: 2.97.0
4
4
  Summary: Python SDK for Chalk
5
5
  Author: Chalk AI, Inc.
6
6
  Project-URL: Homepage, https://chalk.ai
@@ -1,5 +1,5 @@
1
1
  chalk/__init__.py,sha256=vKsx9-cl5kImlVWGHVRYO6bweBm79NAzGs3l36u71wM,2657
2
- chalk/_version.py,sha256=c3gJfSgbDhpHLsXUeqbkrz2gc7ltbdFBTXMLsf03y8U,23
2
+ chalk/_version.py,sha256=AzuYEr2BkAnDfw_LTLHrqH9MJasLCRVWoZmn_HmxL2s,23
3
3
  chalk/cli.py,sha256=ckqqfOI-A2mT23-rnZzDMmblYj-2x1VBX8ebHlIEn9A,5873
4
4
  chalk/importer.py,sha256=m4lMn1lSYj_euDq8CS7LYTBnek9JOcjGJf9-82dJHbA,64441
5
5
  chalk/prompts.py,sha256=2H9UomLAamdfRTNUdKs9i3VTpiossuyRhntqsAXUhhg,16117
@@ -636,7 +636,7 @@ chalk/config/_validator.py,sha256=QC1y52m704_bV_TYjq0sdZJ-km8iSkDX1V4sHgw4RJk,13
636
636
  chalk/config/auth_config.py,sha256=HAALkQrvDD0i7gaZK5iufS8vDDVbzLIpHLOpcJO1kmw,4498
637
637
  chalk/config/project_config.py,sha256=YHB3upvtBJu-tWfNOchBRSc9xGebDbrIpCVmKbBzJ8Q,7217
638
638
  chalk/df/ChalkDataFrameImpl.py,sha256=BRwnjQcie3gxaKhKau8HG17NWzS1zdr8SnNVurxF8QY,133
639
- chalk/df/LazyFramePlaceholder.py,sha256=D4oYEGPfoxpJMmyiDJq3G9Wfl1jF3XSXD71q-GxOrmQ,39398
639
+ chalk/df/LazyFramePlaceholder.py,sha256=6MGwaQRMvgOOqSRl7NC_BsRkiFfzH7eX-ylGH-biNsU,42562
640
640
  chalk/df/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
641
641
  chalk/df/ast_parser.py,sha256=t-DwUxd2hN8LECRSBx85DIv9FtILgMiHyGyCTINfgQw,11199
642
642
  chalk/features/__init__.py,sha256=5doD7bFwRthzwdmizbRaPVHiCABiNpiOiAJVFlwqNnA,6943
@@ -827,8 +827,8 @@ chalk/utils/tracing.py,sha256=NiiM-9dbuJhSCv6R1npR1uYNKWlkqTR6Ygm0Voi2NrY,13078
827
827
  chalk/utils/weak_set_by_identity.py,sha256=VmikA_laYwFeOphCwXJIuyOIkrdlQe0bSzaXq7onoQw,953
828
828
  chalk/utils/pydanticutil/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
829
829
  chalk/utils/pydanticutil/pydantic_compat.py,sha256=O575lLYJ5GvZC4HMzR9yATxf9XwjC6NrDUXbNwZidlE,3031
830
- chalkpy-2.96.9.dist-info/METADATA,sha256=wqwaFPD4aK1rP7orIR_efhtC7u1Q6Iay9TGwaisDQp0,27754
831
- chalkpy-2.96.9.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
832
- chalkpy-2.96.9.dist-info/entry_points.txt,sha256=Vg23sd8icwq-morJrljVFr-kQnMbm95rZfZj5wsZGis,42
833
- chalkpy-2.96.9.dist-info/top_level.txt,sha256=1Q6_19IGYfNxSw50W8tYKEJ2t5HKQ3W9Wiw4ia5yg2c,6
834
- chalkpy-2.96.9.dist-info/RECORD,,
830
+ chalkpy-2.97.0.dist-info/METADATA,sha256=MAiYY-F0FLqqxH6fDhU2KpF3FL38NqmMJJoCiVq8bSY,27754
831
+ chalkpy-2.97.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
832
+ chalkpy-2.97.0.dist-info/entry_points.txt,sha256=Vg23sd8icwq-morJrljVFr-kQnMbm95rZfZj5wsZGis,42
833
+ chalkpy-2.97.0.dist-info/top_level.txt,sha256=1Q6_19IGYfNxSw50W8tYKEJ2t5HKQ3W9Wiw4ia5yg2c,6
834
+ chalkpy-2.97.0.dist-info/RECORD,,