Skip to content

Commit

Permalink
add genesis parse code for regio, too, for the moment.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmayd committed Feb 1, 2024
1 parent 96f0bc1 commit 018cf74
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/pystatis/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,20 @@ def parse_zensus_table(data: pd.DataFrame) -> pd.DataFrame:
@staticmethod
def parse_regio_table(data: pd.DataFrame) -> pd.DataFrame:
"""Parse Regionalstatistik table ffcsv format into a more readable format"""
pass
# Extracts time column with name from first element of Zeit_Label column
time = pd.DataFrame({data["Zeit_Label"].iloc[0]: data["Zeit"]})

# Extracts new column names from first values of the Merkmal_Label columns
# and assigns these to the relevant attribute columns (Auspraegung_Label)
attributes = data.filter(like="Auspraegung_Label")
attributes.columns = data.filter(like="Merkmal_Label").iloc[0].tolist()

# Selects all columns containing the values
values = data.filter(like="__")

# Given a name like BEV036__Bevoelkerung_in_Hauptwohnsitzhaushalten__1000
# extracts the readable label and omit both the code and the unit
values.columns = [name.split("__")[1] for name in values.columns]

pretty_data = pd.concat([time, attributes, values], axis=1)
return pretty_data

0 comments on commit 018cf74

Please sign in to comment.