Skip to content

Commit 9141660

Browse files
Fix wrong join for ephemerides (#167)
* Fix wrong join * Fix missing import for test * Fix layout
1 parent a445bbf commit 9141660

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fink_utils/sso/ssoft.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,23 @@ def join_aggregated_sso_data(df_prev, df_new, on="ssnamenr", output_filename=Non
409409
410410
Examples
411411
--------
412+
Dummy example
413+
>>> import pandas as pd
414+
>>> df1 = spark.createDataFrame(pd.DataFrame({"a": [1, 2, 3], "b": [[1,2], [3,4], [5, 6]]}))
415+
>>> df2 = spark.createDataFrame(pd.DataFrame({"a": [1, 3, 4], "b": [[10,20], [30,40], [50, 60]]}))
416+
>>> df_join = join_aggregated_sso_data(df1, df2, on="a")
417+
>>> df_join.show()
418+
+---+--------------+
419+
| a| b|
420+
+---+--------------+
421+
| 1|[1, 2, 10, 20]|
422+
| 2| [3, 4]|
423+
| 3|[5, 6, 30, 40]|
424+
| 4| [50, 60]|
425+
+---+--------------+
426+
<BLANKLINE>
427+
428+
SSO example
412429
>>> path = "fink_utils/test_data/benoit_julien_2025/science"
413430
>>> df_new = aggregate_ztf_sso_data(year=2025, month=1, prefix_path=path)
414431
>>> path = "fink_utils/test_data/agg_benoit_julien_2024"
@@ -446,7 +463,9 @@ def join_aggregated_sso_data(df_prev, df_new, on="ssnamenr", output_filename=Non
446463
# concatenate
447464
df_concatenated = df_join.withColumns({
448465
col: F.when(F.col(col + "_r").isNull(), F.col(col)).otherwise(
449-
F.concat(F.col(col), F.col(col + "_r"))
466+
F.when(F.col(col).isNull(), F.col(col + "_r")).otherwise(
467+
F.concat(F.col(col), F.col(col + "_r"))
468+
)
450469
)
451470
for col in df_new.columns
452471
if col != on

0 commit comments

Comments
 (0)