Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert text variable to string before NumWords #106

Merged
merged 3 commits into from
Mar 19, 2018
Merged

Convert text variable to string before NumWords #106

merged 3 commits into from
Mar 19, 2018

Conversation

Seth-Rothschild
Copy link
Contributor

This fixes an error that NumWords gives if it encounters a float. This comes up often, as np.NaN is a float. An alternate solution would be to catch the NaNs directly and return 0 or NaN rather than 1.

@codecov-io
Copy link

codecov-io commented Mar 7, 2018

Codecov Report

Merging #106 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
- Coverage   88.18%   88.17%   -0.02%     
==========================================
  Files          73       73              
  Lines        7392     7394       +2     
==========================================
+ Hits         6519     6520       +1     
- Misses        873      874       +1
Impacted Files Coverage Δ
featuretools/primitives/transform_primitive.py 97.77% <100%> (+0.01%) ⬆️
featuretools/utils/gen_utils.py 64.44% <0%> (-2.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4189b0b...59923ba. Read the comment docs.

return lambda array: pd.Series([x.count(" ") + 1 for x in array])
def word_counter(array):
array = pd.Series(array).fillna('')
return pd.Series([str(x).count(' ') + 1 for x in array])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just do pd.Series(array).fillna('').str.count(" ") + 1?

@kmax12 kmax12 merged commit 7e7cfd0 into master Mar 19, 2018
@rwedge rwedge mentioned this pull request Mar 21, 2018
@Seth-Rothschild Seth-Rothschild deleted the textprimfix branch March 30, 2018 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants