Skip to content

Commit bff59de

Browse files
authored
Merge pull request #85 from Crunch-io/update-create-docs-188545853
Update create dataset example
2 parents 9bb0733 + dbb2950 commit bff59de

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,15 @@ each Tuple in a catalog's index, which follows the link to the Entity resource:
128128
}
129129
})
130130

131+
### Creating a New Dataset
132+
131133
You typically add new resources to a Catalog via its `create` method:
132134

133135
>>> ds = site.datasets.create({"body": {
134-
'name': "My first dataset"
135-
}}, refresh=True)
136+
"name": "My first dataset",
137+
"project": "https://your-domain.crunch.io/api/projects/dbf9foo7b727/"
138+
}})
139+
>>> ds.refresh()
136140
>>> gender = ds.variables.create({"body": {
137141
'name': 'Gender',
138142
'alias': 'gender',
@@ -143,15 +147,37 @@ You typically add new resources to a Catalog via its `create` method:
143147
{'id': 2, 'name': 'F', 'numeric_value': None, 'missing': False}
144148
],
145149
'values': [1, 2, {"?": -1}, 2]
146-
}}, refresh=True)
147-
>>> print(ds.table.data)
150+
}})
151+
>>> print(ds.table.metadata)
148152
pycrunch.elements.JSONObject(**{
149-
"e7f361628": [
150-
1,
151-
2,
152-
{"?": -1},
153-
2
154-
]
153+
"dbebef213d3d413398f0c4075acb05a7": {
154+
"alias": "gender",
155+
"name": "Gender",
156+
"type": "categorical",
157+
"description": "",
158+
"notes": "",
159+
"derived": false,
160+
"categories": [
161+
{
162+
"missing": true,
163+
"numeric_value": null,
164+
"id": -1,
165+
"name": "No Data"
166+
},
167+
{
168+
"missing": false,
169+
"numeric_value": null,
170+
"id": 1,
171+
"name": "M"
172+
},
173+
{
174+
"missing": false,
175+
"numeric_value": null,
176+
"id": 2,
177+
"name": "F"
178+
}
179+
]
180+
}
155181
})
156182

157183
To access a Pandas Dataframe of the data in your dataset:

0 commit comments

Comments
 (0)