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

COMPAT: np.full not available in all versions, xref #16773 #17000

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas/core/sparse/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def _init_dict(self, data, index, columns, dtype=None):

# TODO: figure out how to handle this case, all nan's?
# add in any other columns we want to have (completeness)
nan_arr = sp_maker(np.full(len(index), np.nan))
nan_arr = np.empty(len(index), dtype='float64')
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a comment about why we don't use np.full ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, we don't use np.full anywhere in the code base at all (because its not compat with older numpy). you can add that in the numpy compat issue though (e.g. to use it once we move away from 1.7)

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, and I see that you already added it in anticipation. 😄

nan_arr.fill(np.nan)
nan_arr = sp_maker(nan_arr)
sdict.update((c, nan_arr) for c in columns if c not in sdict)

return to_manager(sdict, columns, index)
Expand Down