toolsos 0.2.7__py3-none-any.whl → 0.2.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
toolsos/geo.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Any, Union
4
4
 
5
+ import geopandas as gpd
5
6
  import requests
6
7
 
7
8
 
@@ -43,6 +44,14 @@ def get_geo_json(
43
44
  return json
44
45
 
45
46
 
47
+ def get_geo_dataframe(
48
+ level: str, year: Union[int, Any], with_water: bool = False, mra: bool = False
49
+ ):
50
+ return gpd.read_file(
51
+ get_geo_json(level=level, year=year, with_water=with_water, mra=mra)
52
+ )
53
+
54
+
46
55
  def extract_name_code_table(geo_json: dict[str, str]) -> dict[str, str]:
47
56
  """_summary_
48
57
 
@@ -278,7 +278,14 @@ def get_cols_id_with_pattern(df: pd.DataFrame, pattern: str) -> list[int]:
278
278
  Returns:
279
279
  list[int]: list with column indices matching pattern
280
280
  """
281
- return [idx for idx, col in enumerate(df.columns) if re.findall(pattern, col)]
281
+
282
+ if isinstance(df.columns, pd.MultiIndex):
283
+ # Use the lowest level in the multi-index column
284
+ return [
285
+ idx for idx, col in enumerate(df.columns) if re.findall(pattern, col[-1])
286
+ ]
287
+ else:
288
+ return [idx for idx, col in enumerate(df.columns) if re.findall(pattern, col)]
282
289
 
283
290
 
284
291
  def get_string_cols_ids(df: pd.DataFrame) -> list[int]:
@@ -702,6 +709,7 @@ def format_worksheet(
702
709
  "The number of widths defined in column_widths should be equal to the number of columsn in the dataframe"
703
710
  )
704
711
  col_widths = column_widths
712
+
705
713
  elif (autofit_columns == "column_names") or (autofit_columns is None):
706
714
  col_widths = get_max_col_widths(df)
707
715
  elif autofit_columns == "all_data":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: toolsos
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: OS tools
5
5
  Author-email: OS <d.schmitz@amsterdam.nl>
6
6
  Keywords: tools,Onderzoek & Statistiek
@@ -2,7 +2,7 @@ toolsos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  toolsos/cbs_tools.py,sha256=361cogk0aIU4D4BKHaa7YSOBh64t5C3zrHlqtWx0iIc,3465
3
3
  toolsos/create_tables.py,sha256=43FHK3EERjumBtnGhngIdtthZzcc_Qi37lJ1MgATzBg,908
4
4
  toolsos/download.py,sha256=88hehmPL5m5d1nrcJjltuh4xrCItF5EYHaZdHOcSt-g,2652
5
- toolsos/geo.py,sha256=w0Bt0JJEILEjKtmKw97rHkVixkgbATS-uAQUV6WCHfQ,2598
5
+ toolsos/geo.py,sha256=AUPwGCsIjS_JktiyK4D8LQUq1y-kXx_PUMWzScgkBc8,2851
6
6
  toolsos/helpers.py,sha256=VeOl-fLgePCbjEmAQdVmYe7z8OE1pISeDDuP1t5QSxM,997
7
7
  toolsos/polars_helpers.py,sha256=P3RHLQFeDL7-9U_Q1n4ma_NSkdYAiker4pnc57uluHw,770
8
8
  toolsos/database/database_connection.py,sha256=HCP8H_-iE2BOOQDp9v1HOgfUSX45XS-aqw7Nzf8drAU,4359
@@ -19,8 +19,8 @@ toolsos/huisstijl/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
19
19
  toolsos/huisstijl/tables/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  toolsos/huisstijl/tables/table_helpers.py,sha256=jsQ6lw93sxtGJGrUn8X2_LyA2vYYnytngpUI5A_wpWQ,2037
21
21
  toolsos/huisstijl/tables/table_styles.py,sha256=oYU6GJcfqlKpZof5PUjPsA7woJ3Tew78CHPyT0_jY6w,1343
22
- toolsos/huisstijl/tables/tables.py,sha256=w_8_KJhKDOxaLHouOYRG0pupgEqxy0qtty1DWD3rYc0,24488
23
- toolsos-0.2.7.dist-info/METADATA,sha256=CzVk1Oi9ZEDuXdIEVssMaX8sAL-d77ij8qz2o1BwmgM,2683
24
- toolsos-0.2.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
- toolsos-0.2.7.dist-info/top_level.txt,sha256=2ClEjUBbtfDQ8oPwvWRy1Sz2nrkLCXlg0mHaMdCWia0,8
26
- toolsos-0.2.7.dist-info/RECORD,,
22
+ toolsos/huisstijl/tables/tables.py,sha256=yeHiZd4EuOoeb_CeRE74xM1r1j6gCMNM1-I3Lpd2tyQ,24728
23
+ toolsos-0.2.8.dist-info/METADATA,sha256=1copLfCg6pko0yR08KsSLxsVKiXmxS6iLEV-oMghV7I,2683
24
+ toolsos-0.2.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
+ toolsos-0.2.8.dist-info/top_level.txt,sha256=2ClEjUBbtfDQ8oPwvWRy1Sz2nrkLCXlg0mHaMdCWia0,8
26
+ toolsos-0.2.8.dist-info/RECORD,,