Created
March 11, 2020 22:38
-
-
Save jazzyjackson/dfeb861720f44a334878119c72ae89ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# must be run with pyvalidate in PYTHONPATH | |
# condavision uses PYTHONPATH to check dependencies | |
import pandas,numpy | |
import StringIO, time | |
import pyvalidate | |
valid = pyvalidate.parameters({ | |
"rows": { | |
"type":"number::int", | |
"info":"number of rows", | |
"placeholder":"for example: 3", | |
"verify":"^\d+$" | |
}, | |
"cols": { | |
"type":"number::int", | |
"info":"number of columns", | |
"placeholder":"for example: 5", | |
"verify":"^\d+$" | |
}, | |
"file": { | |
"info": "Where should the result be saved?", | |
"type": "text::buffer", | |
"value": 'example' + str(int(time.time())) + '.csv', | |
"verify": "^[A-Za-z0-9.-]+$" # restrict filename if you want | |
}, | |
"labels": { | |
"type":"text::bool", | |
"info":"Whether to print row and column labels", | |
"verify":"(?i)^(true|false)$", | |
"placeholder": "True or False" | |
} | |
}) | |
# Guassian distribution | |
samples = pandas.DataFrame(numpy.random.rand(valid.rows, valid.cols)) | |
print(samples) | |
valid.file.write(samples.to_csv( | |
index=valid.get('labels', False), | |
header=valid.get('labels', False), | |
)) | |
valid.file.close() | |
valid.output({'download': valid.file.name }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment