python-esios 0.1.3__tar.gz → 0.1.4__tar.gz
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.
- {python_esios-0.1.3 → python_esios-0.1.4}/PKG-INFO +1 -1
- {python_esios-0.1.3 → python_esios-0.1.4}/esios/endpoints/indicators/__init__.py +17 -14
- {python_esios-0.1.3 → python_esios-0.1.4}/python_esios.egg-info/PKG-INFO +1 -1
- {python_esios-0.1.3 → python_esios-0.1.4}/setup.py +1 -1
- {python_esios-0.1.3 → python_esios-0.1.4}/LICENSE +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/README.md +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/esios/__init__.py +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/esios/api_client.py +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/esios/endpoints/__init__.py +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/python_esios.egg-info/SOURCES.txt +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/python_esios.egg-info/dependency_links.txt +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/python_esios.egg-info/requires.txt +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/python_esios.egg-info/top_level.txt +0 -0
- {python_esios-0.1.3 → python_esios-0.1.4}/setup.cfg +0 -0
|
@@ -87,6 +87,10 @@ class Indicators(APIClient):
|
|
|
87
87
|
response = self._api_call('GET', endpoint, params=params)
|
|
88
88
|
return IndicatorData(response.json())
|
|
89
89
|
|
|
90
|
+
class IndicatorData:
|
|
91
|
+
def __init__(self, data):
|
|
92
|
+
self.data = data
|
|
93
|
+
|
|
90
94
|
class IndicatorData:
|
|
91
95
|
def __init__(self, data):
|
|
92
96
|
self.data = data
|
|
@@ -109,18 +113,19 @@ class IndicatorData:
|
|
|
109
113
|
|
|
110
114
|
if values:
|
|
111
115
|
df = pd.DataFrame(values)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
mask = columns.str.contains('time')
|
|
116
|
+
if 'datetime' in df.columns:
|
|
117
|
+
df['datetime'] = pd.to_datetime(df['datetime'], utc=True)
|
|
118
|
+
df = df.set_index('datetime')
|
|
119
|
+
df.index = df.index.tz_convert('Europe/Madrid')
|
|
117
120
|
|
|
118
|
-
|
|
121
|
+
# Drop all columns that contain the word 'time' in them
|
|
122
|
+
df = df[[col for col in df.columns if not 'time' in col]]
|
|
119
123
|
|
|
120
|
-
if column_name
|
|
121
|
-
|
|
124
|
+
# Rename 'value' column if a different column_name is requested
|
|
125
|
+
if column_name in data and column_name != 'value':
|
|
126
|
+
df.rename(columns={'value': data[column_name]}, inplace=True)
|
|
122
127
|
|
|
123
|
-
return df
|
|
128
|
+
return df
|
|
124
129
|
else:
|
|
125
130
|
return pd.DataFrame()
|
|
126
131
|
|
|
@@ -133,9 +138,7 @@ class IndicatorData:
|
|
|
133
138
|
dict
|
|
134
139
|
A dictionary containing the metadata of the indicator.
|
|
135
140
|
"""
|
|
141
|
+
metadata = self.data.get('indicator', {}).copy() # Use a copy to avoid mutating original data
|
|
142
|
+
metadata.pop('values', None) # Remove values key to extract only metadata
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
metadata = self.data.get('indicator', {})
|
|
139
|
-
metadata.pop('values', None)
|
|
140
|
-
|
|
141
|
-
return metadata
|
|
144
|
+
return metadata
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|