Skip to content

Instantly share code, notes, and snippets.

@kubaracek
Created April 28, 2017 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubaracek/31df443f7b0c35339710c74ff52f5c4c to your computer and use it in GitHub Desktop.
Save kubaracek/31df443f7b0c35339710c74ff52f5c4c to your computer and use it in GitHub Desktop.
def convert_to_chronicle_format(weights: pd.Series) -> Generator[Dict[str, Dict[str, float]], Any, None]:
"""Take out panelprovider on the beginning of respondents
index and returns generator with format suitable for
pychronicle
Args:
weights: Series with weightings data
Returns:
generator with dicts containing respondents weighting
"""
return (
{
'_id': idx,
'_source': {'weighting': vals},
'_index': # TODO,
'valid_at': datetime.datetime.utcnow().isoformat()
} for idx, vals in weights.to_dict().items()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment