@@ -28,15 +28,15 @@ def test_read_csv_in_chunk_with_filtered_function(self):
2828 columns = ["col1" , "col2" , "country" ]
2929 )
3030
31- def filter_chunk (df_chunk : pd .DataFrame , countries : list ) -> pd .DataFrame :
32- return df_chunk [ df_chunk ["country" ].isin (countries )]
31+ def filter_chunk (df : pd .DataFrame , countries : list ) -> pd .DataFrame :
32+ return df [ df ["country" ].isin (countries )]
3333
3434 file_path = PATH_TO_AKUTILS_PKG / "tests" / "_fixtures" / "sales.csv"
3535 df = ak .read_csv_in_chunks (
3636 file_path ,
3737 chunk_func = filter_chunk ,
38+ chunk_func_kwarg = {"countries" : ["Spain" ]},
3839 chunksize = 5 ,
39- countries = ["Spain" ],
4040 sep = ";" ,
4141 dtype = None
4242 )
@@ -51,21 +51,23 @@ def test_read_csv_in_chunk_with_add_cols_function(self):
5151 df_expected ["new_col" ] = (df_expected ["col1" ] + df_expected ["col2" ]) * 2.4 + 151
5252
5353 def add_new_col_to_chunk (
54- df_chunk : pd .DataFrame ,
54+ df : pd .DataFrame ,
5555 factor : float ,
5656 constant : int
5757 ) -> pd .DataFrame :
58- df_chunk ["new_col" ] = (
59- (df_chunk ["col1" ] + df_chunk ["col2" ]) * factor + constant
58+ df ["new_col" ] = (
59+ (df ["col1" ] + df ["col2" ]) * factor + constant
6060 )
61- return df_chunk
61+ return df
6262
6363 file_path = PATH_TO_AKUTILS_PKG / "tests" / "_fixtures" / "sales.csv"
6464 df = ak .read_csv_in_chunks (
6565 file_path ,
6666 chunk_func = add_new_col_to_chunk ,
67- factor = 2.4 ,
68- constant = 151 ,
67+ chunk_func_kwarg = {
68+ "factor" : 2.4 ,
69+ "constant" : 151 ,
70+ },
6971 chunksize = 5 ,
7072 sep = ";" ,
7173 dtype = None
@@ -134,8 +136,8 @@ def test_read_multiple_csv_from_dir_with_chunk_function(self):
134136 Case with chunk function (the dir containing also not text file extension)
135137 """
136138
137- def filter_chunk (df_chunk : pd .DataFrame ) -> pd .DataFrame :
138- return df_chunk [ df_chunk ["nb_sales" ] <= 4 ]
139+ def filter_chunk (df : pd .DataFrame ) -> pd .DataFrame :
140+ return df [ df ["nb_sales" ] <= 4 ]
139141
140142 df_expected = self .df_expected .copy ()
141143 df_expected = df_expected [df_expected ["nb_sales" ] <= 4 ]
0 commit comments