Last active
April 15, 2016 10:46
-
-
Save dgonzo/226fe5f610ba9cbc996c7ddbb04fb037 to your computer and use it in GitHub Desktop.
9.2 letter counts
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
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-160-81dcb3a1b66b> in <module>() | |
----> 1 _ = words.apply(update_counts) | |
/Users/gonzo/.pyenv/versions/miniconda3-latest/lib/python3.5/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds) | |
2235 values = lib.map_infer(values, boxer) | |
2236 | |
-> 2237 mapped = lib.map_infer(values, f, convert=convert_dtype) | |
2238 if len(mapped) and isinstance(mapped[0], Series): | |
2239 from pandas.core.frame import DataFrame | |
pandas/src/inference.pyx in pandas.lib.map_infer (pandas/lib.c:63043)() | |
<ipython-input-159-487c851bece5> in update_counts(val) | |
2 def update_counts(val): | |
3 global counts | |
----> 4 for let in val: | |
5 let = let.lower() | |
6 count = counts.get(let, 0) + val.count(let) | |
TypeError: 'float' object is not iterable |
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
words = pd.Series.from_csv(filename, index_col=None, encoding='utf-8') | |
# add this line | |
words.dropna(inplace=True); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment