File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,35 @@ def tree_to_dataframe(root):
135
135
return pd .DataFrame (rows , columns = root .data )
136
136
137
137
138
+ # Extract frequencies from given dataset and subset accordingly
139
+ def freq_eurostat (freqs , la_data ):
140
+ # If "TIME_PERIOD" exists in la_data's axes names, rename it to "time"
141
+ if "TIME_PERIOD" in la_data .axes .names :
142
+ freq_data = la_data .rename (TIME_PERIOD = 'time' )
143
+
144
+ a_time = []
145
+
146
+ for freq in freqs :
147
+ # str() because larray labels are not always strings, might also return ints
148
+ if freq == 'A' :
149
+ a_time += [t for t in freq_data .time .labels if '-' not in str (t )]
150
+ elif freq == 'Q' :
151
+ a_time += [t for t in freq_data .time .labels if 'Q' in str (t )]
152
+ elif freq == 'M' :
153
+ a_time += [t for t in freq_data .time .labels if '-' in t and 'Q' not in str (t )]
154
+
155
+ # Maintain order and use set for non-duplicates
156
+ a_time = sorted (set (a_time ))
157
+
158
+ if len (freqs ) == 1 and freq [0 ] in ['A' , 'Q' , 'M' ]:
159
+ freq_value = str (freqs [0 ])
160
+ else :
161
+ freq_value = freqs
162
+
163
+ # Return with row and colum-wise subsetting
164
+ return freq_data [freq_value , a_time ]
165
+
166
+
138
167
139
168
class FrequencyFilterDialog (QDialog ):
140
169
def __init__ (self , available_labels , parent = None ):
You can’t perform that action at this time.
0 commit comments