From f962672d7c382c47dab327cc251f47704f55f29f Mon Sep 17 00:00:00 2001 From: Luka Peschke Date: Mon, 1 Jul 2024 21:59:31 +0200 Subject: [PATCH] refactor(dtype): automatically cast mixed string and date columns to strings (#245) Signed-off-by: Luka Peschke --- .../fixture-multi-dtypes-columns.xlsx | Bin 9525 -> 7119 bytes python/tests/test_dtypes.py | 21 ++++++++++++++++-- src/types/dtype.rs | 10 ++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/python/tests/fixtures/fixture-multi-dtypes-columns.xlsx b/python/tests/fixtures/fixture-multi-dtypes-columns.xlsx index 3d80b511c6309ff590b7fb0ab902702a55c3772c..4e7211dbd60058700a08dd035680422e28d43879 100644 GIT binary patch literal 7119 zcmaKR1zeO{(D%}abfdI%NC|?pgfs}!9ZNS$E+Nw0-Q6Xr^pcBoN`r`Wcfa7h->292 zy?379#_!pkdCr-c^Pf5YqaY0jj|)IXMh3hyT2=%6CQt6ayI8X5+5;^eSe$L_EevdI zES|eqSw4TbQx-j7-oc9LyXT5hb*AB@Aw?hWK<}-kc?RR#6fb%lpkkI*&q9@FNA64N zu3?PMLDo^10_8pROR_|TO)f_C7w&3DWL~OX6liM8*R0)JH>zTbtP1-2U7H*xKlZqf zhu%j=5f8^7+Q??i@>rS8B0YCTI?P>rYKU)$BeSv3s8LvG0S&G4HgR8Y+K#vkQeTKp zD)Q-Vdx&sEn_ChmJ`AlZSBm)|`ni?=Ni^!aaP$pWyUDXnvV_vRa94T6DlOz&rf&rf z&LIV2^{nhG`)@y@xd}k$ZvE72uQyjelPO3eA-4>_B3iolLJ=$gpzyDL!uZQizk4Vw zTGnBP71Mw31~0kUhgpJ-wKoYDLd9{@3!j_{bPZEBf<9wzuNk{rs0thd&4{qXJ59Nr zPHbvx)z<0{t@}8s0Lb#&h8a{%8*%m>8%brn5u)oNyVY@RApq6s#;%bIkKMWS+S)2% zA+hoP7^*@P3nKq=;n~T2P)j_n|KMKquuH61A!ZR5lunjblDXE8Lx1-!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KMD6^LB#__8&qa{e1rzf<6~0FnnN%Uv)Ay= zIZRl-E_J&fDV2=}Fn&nx{^50|59ZFGw2WM!Wf|7n5nT4oPjUzyN+VJM9mj>oD zrSO=~rG<=n-mGqN@)8j+x|~63GF0#<<8B+0VK(u|KF0d74yySE#6gZ8U2;oA94qnd zd+m9>ax+~9(xEMj81KAG!)L#%4qj9dRJO|G*8~o}=8QBo3y?^awACH`A?8nU+D<}hr0K&QR zV@vuks&S$dy18WVN{4<~#85QbXL_!2KuCoMAtTb~N~IJ*LdQ1dhUg|F2nqSbw|k9v zV7YTQm;Ml)o=|B+!p1*8U!5H7RsJ%0$8inaOaE(Ps+gqZl`a%mWkwim-&_#izVCgx%O#nA=I+CNL+k z%qvKl{i&AzT|wK9pdY`7{(}vT2Hf9Q50I6yi@BMatBbXR{MFX?xpz09j!!#t}v~ZH$#8GLKHZ)^^;Zb#O$)Up#5f~-QnNxI#BhdGwqa!YL<(BdPi= z?k}U~U&#Ha=v@Sz4)Ukwl_Wxf9f5Ta^|1Ab8~|>)N|e@s>9WDerbsiGpoGslB+B6+9+q7l{rg^hIa)gmh!cEbc}t*(8c}cjJHR!_Q_O z5wY>OeU^8^A|9`RZS3AGfoc^$M46Q=_Qi1vv{HqxL2RIQb zk3+$KNaMdkf0fz(fVyJ-qv-alfnN^_e;7C;_|L%qc5L|7%C8%SKdf+){{9BPZXbTN z@Yfvr2Oa=0A_D;amQjC&|8*t&Gkgx3v;PDC*Se@IhX9>j0N@Gq7YI$-@2P*@{U3q4 BxTXLA diff --git a/python/tests/test_dtypes.py b/python/tests/test_dtypes.py index acc5c4e..e155864 100644 --- a/python/tests/test_dtypes.py +++ b/python/tests/test_dtypes.py @@ -40,6 +40,7 @@ def expected_data() -> dict[str, list[Any]]: "Date": [datetime(2023, 7, 21)] * 9, "Details": ["Healthcare"] * 7 + ["Something"] * 2, "Asset ID": ["84444"] * 7 + ["ABC123"] * 2, + "Mixed dates": ["2023-07-21 00:00:00"] * 6 + ["July 23rd"] * 3, } @@ -89,13 +90,29 @@ def test_sheet_with_mixed_dtypes_and_sample_rows(expected_data: dict[str, list[A None, ] expected_data["Asset ID"] = [84444.0] * 7 + [None] * 2 + expected_data["Mixed dates"] = [datetime(2023, 7, 21)] * 6 + [None] * 3 pd_df = sheet.to_pandas() - pd_assert_frame_equal(pd_df, pd.DataFrame(expected_data).astype({"Date": "datetime64[ms]"})) + pd_assert_frame_equal( + pd_df, + pd.DataFrame(expected_data).astype( + { + "Date": "datetime64[ms]", + "Mixed dates": "datetime64[ms]", + } + ), + ) pl_df = sheet.to_polars() pl_assert_frame_equal( - pl_df, pl.DataFrame(expected_data, schema_overrides={"Date": pl.Datetime(time_unit="ms")}) + pl_df, + pl.DataFrame( + expected_data, + schema_overrides={ + "Date": pl.Datetime(time_unit="ms"), + "Mixed dates": pl.Datetime(time_unit="ms"), + }, + ), ) diff --git a/src/types/dtype.rs b/src/types/dtype.rs index 1f30306..5be6596 100644 --- a/src/types/dtype.rs +++ b/src/types/dtype.rs @@ -187,7 +187,15 @@ fn int_types() -> &'static HashSet { } fn string_types() -> &'static HashSet { - STRING_TYPES_CELL.get_or_init(|| HashSet::from([DType::Int, DType::Float, DType::String])) + STRING_TYPES_CELL.get_or_init(|| { + HashSet::from([ + DType::Int, + DType::Float, + DType::String, + DType::DateTime, + DType::Date, + ]) + }) } pub(crate) fn get_dtype_for_column(