Skip to content

Commit

Permalink
Feature/106 parse data types (#148)
Browse files Browse the repository at this point in the history
* Update dependency sphinx to v7.4.4 (#136)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Fix date format for zensus.

* Update dependencies.

* Adjust to new formatting of genesis and zensus.

* Add genesis and zensus tables to test of datetype conversion.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonas Bergner <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 369f8aa commit 8191190
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/pystatis/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def get_data(
decimal="," if language == "de" else ".",
dtype={raw_data_header.split(";")[pos + 2]: str for pos in pos_of_ags_col},
parse_dates=[config.LANG_TO_COL_MAPPING[db_version][language]["time"]],
date_format="%d.%m.%Y" if language == "de" else "%Y-%m-%d",
date_format="%d.%m.%Y"
if (language == "de" and db_name == "regio")
else "%Y-%m-%d",
)

if prettify:
Expand Down
13 changes: 12 additions & 1 deletion tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,18 @@ def test_prettify(
@pytest.mark.vcr()
@pytest.mark.parametrize(
"table_name, time_col, language",
[("12411-01-01-4", "Stichtag", "de"), ("12411-01-01-4", "Stichtag", "en")],
[
("12411-01-01-4", "Stichtag", "de"),
("12411-01-01-4", "Stichtag", "en"),
("13111-0005", "Stichtag", "de"),
("13111-0005", "Reference date", "en"),
("71311-0001", "Stichtag zum Quartalsende", "de"),
("71311-0001", "Reference date end-of-quarter", "en"),
("1000A-0000", "Stichtag", "de"),
("1000A-0000", "Reference date", "en"),
("2000S-2003", "Stichtag", "de"),
("2000S-2003", "Reference date", "en"),
],
)
def test_dtype_time_column(mocker, table_name: str, time_col: str, language: str):
mocker.patch.object(pystatis.db, "check_credentials", return_value=True)
Expand Down

0 comments on commit 8191190

Please sign in to comment.