@@ -193,7 +193,8 @@ def all(self, exprs_src, style: Literal['pandas', 'polars_group', 'polars_over']
193
193
replace : bool = True , regroup : bool = False , format : bool = True ,
194
194
date = 'date' , asset = 'asset' ,
195
195
alias : Dict [str , str ] = {},
196
- extra_codes : Sequence [object ] = ()):
196
+ extra_codes : Sequence [object ] = (),
197
+ ** kwargs ):
197
198
"""功能集成版,将几个功能写到一起方便使用
198
199
199
200
Parameters
@@ -252,7 +253,8 @@ def all(self, exprs_src, style: Literal['pandas', 'polars_group', 'polars_over']
252
253
codes = codegen (exprs_ldl , exprs_src , syms_dst ,
253
254
filename = template_file , date = date , asset = asset ,
254
255
alias = alias ,
255
- extra_codes = extra_codes )
256
+ extra_codes = extra_codes ,
257
+ ** kwargs )
256
258
257
259
if format :
258
260
# 格式化。在遗传算法中没有必要
@@ -267,7 +269,8 @@ def _get_code(self,
267
269
output_file : str ,
268
270
convert_xor : bool ,
269
271
style : Literal ['pandas' , 'polars_group' , 'polars_over' ] = 'polars_over' , template_file : str = 'template.py.j2' ,
270
- date : str = 'date' , asset : str = 'asset' ) -> str :
272
+ date : str = 'date' , asset : str = 'asset' ,
273
+ ** kwargs ) -> str :
271
274
"""通过字符串生成代码, 加了缓存,多次调用不重复生成"""
272
275
raw , exprs_dict = sources_to_exprs (self .globals_ , source , * more_sources , convert_xor = convert_xor )
273
276
@@ -279,7 +282,8 @@ def _get_code(self,
279
282
extra_codes = (raw ,
280
283
# 传入多个列的方法
281
284
extra_codes ,
282
- ))
285
+ ),
286
+ ** kwargs )
283
287
284
288
# 移回到cache,防止多次调用多次保存
285
289
if isinstance (output_file , TextIOWrapper ):
@@ -324,7 +328,8 @@ def codegen_exec(df: Optional[DataFrame],
324
328
style : Literal ['pandas' , 'polars_group' , 'polars_over' ] = 'polars_over' ,
325
329
template_file : str = 'template.py.j2' ,
326
330
date : str = 'date' , asset : str = 'asset' ,
327
- ) -> Optional [DataFrame ]:
331
+ over_null : Literal ['order_by' , 'partition_by' , None ] = 'partition_by' ,
332
+ ** kwargs ) -> Optional [DataFrame ]:
328
333
"""快速转换源代码并执行
329
334
330
335
Parameters
@@ -355,6 +360,11 @@ def codegen_exec(df: Optional[DataFrame],
355
360
时间字段
356
361
asset: str
357
362
资产字段
363
+ over_null: str
364
+ 时序中遇到null时的处理方式
365
+ - order_by: 空值排同一分区的前排
366
+ - partition_by: 空值划分到不同分区
367
+ - None: 不做处理
358
368
359
369
Returns
360
370
-------
@@ -391,6 +401,8 @@ def codegen_exec(df: Optional[DataFrame],
391
401
convert_xor = convert_xor ,
392
402
style = style , template_file = template_file ,
393
403
date = date , asset = asset ,
404
+ over_null = over_null ,
405
+ ** kwargs
394
406
)
395
407
396
408
if df is None :
0 commit comments