Skip to content

BUG: constructing a DataFrame using range doesn't work #26343

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

Merged
merged 2 commits into from
May 12, 2019

Conversation

topper-123
Copy link
Contributor

Fixes bug when constructing a DataFrame using a range.

@pep8speaks
Copy link

pep8speaks commented May 11, 2019

Hello @topper-123! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-05-12 12:19:28 UTC

@topper-123 topper-123 force-pushed the dataframe_range_constructor branch from 502b1f3 to e0f3e54 Compare May 11, 2019 15:36
expected = DataFrame([list(range(10)), list(range(10))])
result = DataFrame([range(10), range(10)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A plain range isn't a iterator, so this fixes up the nomenclature.

The range case is now placed in test_constructor_list_of_ranges, which is clearer.

@codecov
Copy link

codecov bot commented May 11, 2019

Codecov Report

Merging #26343 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26343      +/-   ##
==========================================
- Coverage   92.04%   92.03%   -0.01%     
==========================================
  Files         175      175              
  Lines       52292    52292              
==========================================
- Hits        48133    48128       -5     
- Misses       4159     4164       +5
Flag Coverage Δ
#multiple 90.59% <100%> (ø) ⬆️
#single 40.71% <100%> (-0.14%) ⬇️
Impacted Files Coverage Δ
pandas/core/dtypes/cast.py 91.54% <100%> (ø) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.01% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.6% <0%> (-0.11%) ⬇️

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 bb0376c...e0f3e54. Read the comment docs.

@codecov
Copy link

codecov bot commented May 11, 2019

Codecov Report

Merging #26343 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26343      +/-   ##
==========================================
- Coverage   92.04%   92.03%   -0.01%     
==========================================
  Files         175      175              
  Lines       52292    52292              
==========================================
- Hits        48132    48128       -4     
- Misses       4160     4164       +4
Flag Coverage Δ
#multiple 90.59% <100%> (ø) ⬆️
#single 40.71% <100%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/core/dtypes/cast.py 91.54% <100%> (ø) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.01% <0%> (-0.12%) ⬇️

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 681a22c...96706f0. Read the comment docs.

@gfyoung gfyoung added DataFrame DataFrame data structure Bug labels May 11, 2019
@@ -258,7 +258,10 @@ Performance Improvements
Bug Fixes
~~~~~~~~~

DataFrame
^^^^^^^^^^^
Copy link
Member

Choose a reason for hiding this comment

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

Too many "^" (just enough to funderline DataFrame)


- Fixed a bug where Constructing a :class:`DataFrame` using a ``range`` (e.g. ``pd.DataFrame(range(3))``) would cause an ``AttributeException`` (:issue:`26342`).
Copy link
Member

Choose a reason for hiding this comment

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

I think you meant AttributeError

tm.assert_frame_equal(result, expected)

def test_constructor_list_of_ranges(self):
result = DataFrame([range(10), range(10)])
Copy link
Member

Choose a reason for hiding this comment

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

I would reference the issue as a comment above this line as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, this is just an existing test that has been moved. It already passed before this PR.

Copy link
Member

@gfyoung gfyoung left a comment

Choose a reason for hiding this comment

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

Will need to wait on fixing the Windows build, but the patch looks good!

cc @jreback

@jreback
Copy link
Contributor

jreback commented May 11, 2019

i will comment later

@@ -258,7 +258,10 @@ Performance Improvements
Bug Fixes
~~~~~~~~~

DataFrame
Copy link
Contributor

Choose a reason for hiding this comment

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

just put this in the reshaping section, don't create a new one


- Fixed a bug where Constructing a :class:`DataFrame` using a ``range`` (e.g. ``pd.DataFrame(range(3))``) would cause an ``AttributeException`` (:issue:`26342`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug in construction of a :class:`DataFrame` using a range object (:issue:....)

no need to be more verbose; we rarely mention the original error received

@topper-123 topper-123 force-pushed the dataframe_range_constructor branch from 6332b6c to 48bc320 Compare May 11, 2019 19:47
@topper-123 topper-123 force-pushed the dataframe_range_constructor branch from 48bc320 to 96706f0 Compare May 12, 2019 12:19
@topper-123
Copy link
Contributor Author

This passes now.

@jreback jreback added this to the 0.25.0 milestone May 12, 2019
@jreback jreback merged commit 2f6a0c9 into pandas-dev:master May 12, 2019
@jreback
Copy link
Contributor

jreback commented May 12, 2019

thanks @topper-123

@topper-123 topper-123 deleted the dataframe_range_constructor branch May 12, 2019 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug DataFrame DataFrame data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constructing DataFrames using range fails
4 participants