Skip to content

Commit cd533be

Browse files
committed
version 0.1
1 parent 2f2afb6 commit cd533be

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

ddf_utils/chef/cook.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,14 @@ def dish_to_csv(dishes, outpath):
212212
if t == 'datapoints':
213213
df = df.set_index(by)
214214
if not np.issubdtype(df[k].dtype, np.number):
215-
df[k] = df[k].astype(float)
216-
# TODO: better handle the float format.
217-
df[k] = df[k].map(lambda x: format_float_digits(x, 5))
215+
try:
216+
df[k] = df[k].astype(float)
217+
# TODO: better handle the float format.
218+
df[k] = df[k].map(lambda x: format_float_digits(x, 5))
219+
except ValueError:
220+
logging.warning("data not numeric: " + k)
221+
else:
222+
df[k] = df[k].map(lambda x: format_float_digits(x, 5))
218223
df[[k]].to_csv(path)
219224
else:
220225
df.to_csv(path, index=False)

ddf_utils/chef/ingredient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def dtype(self):
5151
"""
5252
returns the type of ddf data, i.e. concepts/entities/datapoints.
5353
54-
It will be inferred from the key porperity of ingredient.
54+
It will be inferred from the key property of ingredient.
5555
TODO: what if key == '*'? Is it possible?
5656
"""
5757
if self.key == 'concept':

ddf_utils/str.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def format_float_digits(number, digits=5, threshold=None):
7272
# d = decimal.Decimal(number)
7373
# except TypeError:
7474
# d = _float_to_decimal(float(number))
75+
#FIXME: deal with nan
7576

7677
d = float(number)
7778

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='ddf_utils',
8-
version='0.0.4-dev',
8+
version='0.1.0-dev',
99
description='Commonly used functions/utilities for DDF file model.',
1010
url='https://github.com/semio/ddf_utils',
1111
author='Semio Zheng',

0 commit comments

Comments
 (0)