Commit 0e60af8c authored by Akshay G's avatar Akshay G

Handling empty dataframe

parent 451dceb8
...@@ -84,7 +84,14 @@ def get_data(query): ...@@ -84,7 +84,14 @@ def get_data(query):
[KariosConstants.VALUES_KEY] [KariosConstants.VALUES_KEY]
df = DataFrame.from_dict(data) df = DataFrame.from_dict(data)
logger.debug("Dataframe --> {}".format(df.head())) logger.debug("Dataframe --> {}".format(df.head()))
df.columns = [KariosConstants.TIMESTAMP_COLUMN_NAME, list(config[KariosConstants.TAG_HIERARCHY_KEY].keys())[0]]
if len(df) > 0:
df.columns = [KariosConstants.TIMESTAMP_COLUMN_NAME, list(config[KariosConstants.TAG_HIERARCHY_KEY].keys())
[0]]
else:
logger.warn("The dataframe is empty!")
df = DataFrame(columns=[KariosConstants.TIMESTAMP_COLUMN_NAME, list(config[KariosConstants.
TAG_HIERARCHY_KEY].keys())[0]])
return df return df
else: else:
raise Exception(response.json()[KariosConstants.ERRORS_KEY]) raise Exception(response.json()[KariosConstants.ERRORS_KEY])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment