@@ -1796,7 +1796,7 @@ def _computations_pivot_wider(
1796
1796
return df
1797
1797
1798
1798
1799
- class CATEGORY_ORDER (Enum ):
1799
+ class CategoryOrder (Enum ):
1800
1800
"""
1801
1801
order types for encode_categorical.
1802
1802
"""
@@ -1931,7 +1931,7 @@ def as_categorical_checks(df: pd.DataFrame, **kwargs) -> dict:
1931
1931
if order is not None :
1932
1932
check ("order" , order , [str ])
1933
1933
1934
- category_order_types = [ent .value for ent in CATEGORY_ORDER ]
1934
+ category_order_types = [ent .value for ent in CategoryOrder ]
1935
1935
if order .lower () not in category_order_types :
1936
1936
raise ValueError (
1937
1937
"""
@@ -1973,13 +1973,13 @@ def _computations_as_categorical(df: pd.DataFrame, **kwargs) -> pd.DataFrame:
1973
1973
if (cat is None ) and (order is None ):
1974
1974
cat_dtype = pd .CategoricalDtype ()
1975
1975
1976
- elif (cat is None ) and (order is CATEGORY_ORDER .SORT .value ):
1976
+ elif (cat is None ) and (order is CategoryOrder .SORT .value ):
1977
1977
cat = df [column_name ].factorize (sort = True )[- 1 ]
1978
1978
if cat .empty :
1979
1979
raise ValueError (error_msg )
1980
1980
cat_dtype = pd .CategoricalDtype (categories = cat , ordered = True )
1981
1981
1982
- elif (cat is None ) and (order is CATEGORY_ORDER .APPEARANCE .value ):
1982
+ elif (cat is None ) and (order is CategoryOrder .APPEARANCE .value ):
1983
1983
cat = df [column_name ].factorize (sort = False )[- 1 ]
1984
1984
if cat .empty :
1985
1985
raise ValueError (error_msg )
@@ -2265,7 +2265,7 @@ def _column_sel_dispatch(columns_to_select, df): # noqa: F811
2265
2265
return filtered_columns
2266
2266
2267
2267
2268
- class JOINOPERATOR (Enum ):
2268
+ class JoinOperator (Enum ):
2269
2269
"""
2270
2270
List of operators used in conditional_join.
2271
2271
"""
@@ -2278,7 +2278,7 @@ class JOINOPERATOR(Enum):
2278
2278
NOT_EQUAL = "!="
2279
2279
2280
2280
2281
- class JOINTYPES (Enum ):
2281
+ class JoinTypes (Enum ):
2282
2282
"""
2283
2283
List of join types for conditional_join.
2284
2284
"""
@@ -2295,7 +2295,7 @@ def _check_operator(op: str):
2295
2295
2296
2296
Used in `conditional_join`.
2297
2297
"""
2298
- sequence_of_operators = {op .value for op in JOINOPERATOR }
2298
+ sequence_of_operators = {op .value for op in JoinOperator }
2299
2299
if op not in sequence_of_operators :
2300
2300
raise ValueError (
2301
2301
f"""
@@ -2399,7 +2399,7 @@ def _conditional_join_preliminary_checks(
2399
2399
2400
2400
check ("how" , how , [str ])
2401
2401
2402
- join_types = {jointype .value for jointype in JOINTYPES }
2402
+ join_types = {jointype .value for jointype in JoinTypes }
2403
2403
if how not in join_types :
2404
2404
raise ValueError (f"`how` should be one of { ', ' .join (join_types )} ." )
2405
2405
@@ -2451,7 +2451,7 @@ def _conditional_join_type_check(
2451
2451
2452
2452
if (
2453
2453
is_categorical_dtype (left_column )
2454
- and op != JOINOPERATOR .STRICTLY_EQUAL .value
2454
+ and op != JoinOperator .STRICTLY_EQUAL .value
2455
2455
):
2456
2456
raise ValueError (
2457
2457
"""
@@ -2462,7 +2462,7 @@ def _conditional_join_type_check(
2462
2462
2463
2463
if (
2464
2464
is_string_dtype (left_column )
2465
- and op != JOINOPERATOR .STRICTLY_EQUAL .value
2465
+ and op != JoinOperator .STRICTLY_EQUAL .value
2466
2466
):
2467
2467
raise ValueError (
2468
2468
"""
@@ -2767,14 +2767,14 @@ def _create_conditional_join_empty_frame(
2767
2767
df .columns = pd .MultiIndex .from_product ([["left" ], df .columns ])
2768
2768
right .columns = pd .MultiIndex .from_product ([["right" ], right .columns ])
2769
2769
2770
- if how == JOINTYPES .INNER .value :
2770
+ if how == JoinTypes .INNER .value :
2771
2771
df = df .dtypes .to_dict ()
2772
2772
right = right .dtypes .to_dict ()
2773
2773
df = {** df , ** right }
2774
2774
df = {key : pd .Series ([], dtype = value ) for key , value in df .items ()}
2775
2775
return pd .DataFrame (df )
2776
2776
2777
- if how == JOINTYPES .LEFT .value :
2777
+ if how == JoinTypes .LEFT .value :
2778
2778
right = right .dtypes .to_dict ()
2779
2779
right = {
2780
2780
key : float if dtype .kind == "i" else dtype
@@ -2786,7 +2786,7 @@ def _create_conditional_join_empty_frame(
2786
2786
right = pd .DataFrame (right )
2787
2787
return df .join (right , how = how , sort = False )
2788
2788
2789
- if how == JOINTYPES .RIGHT .value :
2789
+ if how == JoinTypes .RIGHT .value :
2790
2790
df = df .dtypes .to_dict ()
2791
2791
df = {
2792
2792
key : float if dtype .kind == "i" else dtype
@@ -2817,31 +2817,31 @@ def _create_conditional_join_frame(
2817
2817
df .columns = pd .MultiIndex .from_product ([["left" ], df .columns ])
2818
2818
right .columns = pd .MultiIndex .from_product ([["right" ], right .columns ])
2819
2819
2820
- if how == JOINTYPES .INNER .value :
2820
+ if how == JoinTypes .INNER .value :
2821
2821
df = df .loc [left_index ]
2822
2822
right = right .loc [right_index ]
2823
2823
df .index = pd .RangeIndex (start = 0 , stop = left_index .size )
2824
2824
right .index = df .index
2825
2825
return pd .concat ([df , right ], axis = "columns" , join = how , sort = False )
2826
2826
2827
- if how == JOINTYPES .LEFT .value :
2827
+ if how == JoinTypes .LEFT .value :
2828
2828
right = right .loc [right_index ]
2829
2829
right .index = left_index
2830
2830
return df .join (right , how = how , sort = False ).reset_index (drop = True )
2831
2831
2832
- if how == JOINTYPES .RIGHT .value :
2832
+ if how == JoinTypes .RIGHT .value :
2833
2833
df = df .loc [left_index ]
2834
2834
df .index = right_index
2835
2835
return df .join (right , how = how , sort = False ).reset_index (drop = True )
2836
2836
2837
2837
2838
2838
less_than_join_types = {
2839
- JOINOPERATOR .LESS_THAN .value ,
2840
- JOINOPERATOR .LESS_THAN_OR_EQUAL .value ,
2839
+ JoinOperator .LESS_THAN .value ,
2840
+ JoinOperator .LESS_THAN_OR_EQUAL .value ,
2841
2841
}
2842
2842
greater_than_join_types = {
2843
- JOINOPERATOR .GREATER_THAN .value ,
2844
- JOINOPERATOR .GREATER_THAN_OR_EQUAL .value ,
2843
+ JoinOperator .GREATER_THAN .value ,
2844
+ JoinOperator .GREATER_THAN_OR_EQUAL .value ,
2845
2845
}
2846
2846
2847
2847
@@ -2856,17 +2856,17 @@ def _generic_func_cond_join(
2856
2856
strict = False
2857
2857
2858
2858
if op in {
2859
- JOINOPERATOR .GREATER_THAN .value ,
2860
- JOINOPERATOR .LESS_THAN .value ,
2861
- JOINOPERATOR .NOT_EQUAL .value ,
2859
+ JoinOperator .GREATER_THAN .value ,
2860
+ JoinOperator .LESS_THAN .value ,
2861
+ JoinOperator .NOT_EQUAL .value ,
2862
2862
}:
2863
2863
strict = True
2864
2864
2865
2865
if op in less_than_join_types :
2866
2866
return _less_than_indices (left_c , right_c , strict , len_conditions )
2867
2867
elif op in greater_than_join_types :
2868
2868
return _greater_than_indices (left_c , right_c , strict , len_conditions )
2869
- elif op == JOINOPERATOR .NOT_EQUAL .value :
2869
+ elif op == JoinOperator .NOT_EQUAL .value :
2870
2870
return _not_equal_indices (left_c , right_c )
2871
2871
else :
2872
2872
return _equal_indices (left_c , right_c , len_conditions )
@@ -2906,7 +2906,7 @@ def _conditional_join_compute(
2906
2906
2907
2907
_conditional_join_type_check (left_c , right_c , op )
2908
2908
2909
- if op == JOINOPERATOR .STRICTLY_EQUAL .value :
2909
+ if op == JoinOperator .STRICTLY_EQUAL .value :
2910
2910
eq_check = True
2911
2911
elif op in less_greater_types :
2912
2912
less_great = True
@@ -2955,12 +2955,12 @@ def _conditional_join_compute(
2955
2955
2956
2956
2957
2957
operator_map = {
2958
- JOINOPERATOR .STRICTLY_EQUAL .value : operator .eq ,
2959
- JOINOPERATOR .LESS_THAN .value : operator .lt ,
2960
- JOINOPERATOR .LESS_THAN_OR_EQUAL .value : operator .le ,
2961
- JOINOPERATOR .GREATER_THAN .value : operator .gt ,
2962
- JOINOPERATOR .GREATER_THAN_OR_EQUAL .value : operator .ge ,
2963
- JOINOPERATOR .NOT_EQUAL .value : operator .ne ,
2958
+ JoinOperator .STRICTLY_EQUAL .value : operator .eq ,
2959
+ JoinOperator .LESS_THAN .value : operator .lt ,
2960
+ JoinOperator .LESS_THAN_OR_EQUAL .value : operator .le ,
2961
+ JoinOperator .GREATER_THAN .value : operator .gt ,
2962
+ JoinOperator .GREATER_THAN_OR_EQUAL .value : operator .ge ,
2963
+ JoinOperator .NOT_EQUAL .value : operator .ne ,
2964
2964
}
2965
2965
2966
2966
@@ -2977,12 +2977,12 @@ def _multiple_conditional_join_eq(
2977
2977
eq_cond = [
2978
2978
cond
2979
2979
for cond in conditions
2980
- if cond [- 1 ] == JOINOPERATOR .STRICTLY_EQUAL .value
2980
+ if cond [- 1 ] == JoinOperator .STRICTLY_EQUAL .value
2981
2981
]
2982
2982
rest = [
2983
2983
cond
2984
2984
for cond in conditions
2985
- if cond [- 1 ] != JOINOPERATOR .STRICTLY_EQUAL .value
2985
+ if cond [- 1 ] != JoinOperator .STRICTLY_EQUAL .value
2986
2986
]
2987
2987
2988
2988
# get rid of nulls, if any
@@ -3015,7 +3015,7 @@ def _multiple_conditional_join_eq(
3015
3015
# get join indices
3016
3016
# these are positional, not label indices
3017
3017
result = _generic_func_cond_join (
3018
- left_c , right_c , JOINOPERATOR .STRICTLY_EQUAL .value , 2
3018
+ left_c , right_c , JoinOperator .STRICTLY_EQUAL .value , 2
3019
3019
)
3020
3020
3021
3021
if result is None :
@@ -3109,7 +3109,7 @@ def _multiple_conditional_join_le_lt(
3109
3109
lt_gt = left_on , right_on , op
3110
3110
# no point checking for `!=`, since best case scenario
3111
3111
# they'll have the same no of rows for the less/greater operators
3112
- elif op == JOINOPERATOR .NOT_EQUAL .value :
3112
+ elif op == JoinOperator .NOT_EQUAL .value :
3113
3113
continue
3114
3114
3115
3115
left_c = df .loc [df_index , left_on ]
0 commit comments