Quantipy / quantipy

Python for people data
MIT License
66 stars 14 forks source link

example export to .mdd/.ddf #1325

Open scottporter opened 4 years ago

scottporter commented 4 years ago

I am just starting out with Quantipy. I wanted to try the export to .mdd/.ddf but couldn't get it to work on the example dataset in the readme. Is there any reason why following up the tutorial steps with a call to write_dimensions shouldn't work?

import pandas as pd
import quantipy as qp

from quantipy.core.tools.dp.prep import frange

# This is a handy bit of pandas code to let you display your dataframes
# without having them split to fit a vertical column.
pd.set_option('display.expand_frame_repr', False)

# Define the paths of your input files
path_json = './data/Example Data (A).json'
path_csv = './data/Example Data (A).csv'

dataset = qp.DataSet('Example Data (A)')
dataset.read_quantipy(path_json, path_csv)

dataset.write_dimensions(path_mdd='example_a.mdd',path_ddf='example_a.ddf')

## Also tried this but same error
#qp.write_dimensions(dataset._meta,dataset._data,path_mdd='example_a.mdd',path_ddf='example_a.ddf')

Instead I get an error... KeyError: u'time'

Is there some reason this dataset shouldn't work with write_dimensions? Am I doing something wrong? If it's just user error would it be possible to add something to the documentation and/or the tests that make it clear how this function is supposed to work with an example? E.g. round tripping out to .mdd/.ddf and back in and comparing?