Skip to content

Commit

Permalink
Don't use a mask when unboxing Values using applymap as it can alter …
Browse files Browse the repository at this point in the history
…the dataframe types.

E.g. object->float, resulting in non-float values becoming nan.
  • Loading branch information
tonyroberts committed Sep 8, 2015
1 parent 873b4ae commit 2688be7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -9,7 +9,7 @@
description="A Python package to ease writing tables of data to Excel",
packages=find_packages(),
test_suite="nose.collector",
version="0.2.2",
version="0.2.3",
install_requires=["pandas>=0.12.0"],
extras_require={
"xlsxwriter": ["xlsxwriter>=0.7.2"],
Expand Down
5 changes: 2 additions & 3 deletions xltable/table.py
Expand Up @@ -220,9 +220,8 @@ def get_formula(df, element):
df[mask_df] = index_df[mask_df].applymap(partial(get_formula, df))

# replace any Cell instances with their value
mask_df = df.applymap(lambda x: isinstance(x, Value))
if mask_df.any().any():
df[mask_df] = df[mask_df].applymap(lambda x: x.value if isinstance(x, Value) else x)
if df.applymap(lambda x: isinstance(x, Value)).any().any():
df = df.applymap(lambda x: x.value if isinstance(x, Value) else x)

# add the index and or columns to the values part of the dataframe
if self.__include_index or self.__include_columns:
Expand Down

0 comments on commit 2688be7

Please sign in to comment.