Skip to content

Convert to native datatypes for Series.tolist() #13050

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

Closed
wants to merge 1 commit into from
Closed

Convert to native datatypes for Series.tolist() #13050

wants to merge 1 commit into from

Conversation

gliptak
Copy link
Contributor

@gliptak gliptak commented May 1, 2016

@@ -82,6 +82,14 @@ def test_to_csv_unicode_index(self):

assert_series_equal(s, s2)

def test_tolist_np(self):
# GH10904
np_array = np.array([1, 2, 3])
Copy link
Contributor

Choose a reason for hiding this comment

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

pls check for all dtypes (well the numeric ones). Further construct against an absolute test, rather than again what numpy does. E.g. you want to check that things are actually python integers, floats etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

revised

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Compat pandas objects compatability with Numpy or Python functions labels May 1, 2016
@codecov-io
Copy link

codecov-io commented May 1, 2016

Current coverage is 84.15%

Merging #13050 into master will increase coverage by +<.01%

@@             master     #13050   diff @@
==========================================
  Files           137        137          
  Lines         50261      50214    -47   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          42288      42253    -35   
+ Misses         7973       7961    -12   
  Partials          0          0          
  1. 2 files (not in diff) in pandas/tseries were modified. more
    • Misses -4
    • Hits -22
  2. 2 files (not in diff) in pandas/io were modified. more
    • Misses -3
    • Hits -3
  3. 2 files (not in diff) in pandas/core were modified. more
    • Misses -5
    • Hits -8
  4. 1 files (not in diff) in pandas were modified. more
    • Hits -2

Powered by Codecov. Last updated by 1296ab3...18ccde4

@@ -82,6 +82,26 @@ def test_to_csv_unicode_index(self):

assert_series_equal(s, s2)

def test_tolist_np_int(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

no, do this in a list inside a single tests. copy-pasting code is bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@gliptak
Copy link
Contributor Author

gliptak commented May 2, 2016

I will correct this under 2.7

======================================================================

FAIL: test_tolist_np_uint (pandas.tests.series.test_io.TestSeriesIO)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/pydata/pandas/pandas/tests/series/test_io.py", line 93, in test_tolist_np_uint

    for t in ['uint8', 'uint16', 'uint32', 'uint64']]

AssertionError: <type 'long'> != <type 'int'>

----------------------------------------------------------------------

@gliptak
Copy link
Contributor Author

gliptak commented May 2, 2016

Please review

# GH10904
[self.assertEqual(type(pd.Series([1], dtype=t).tolist()[0]), int)
for t in ['uint8', 'uint16']]
if sys.version_info[0] < 3:
Copy link
Member

Choose a reason for hiding this comment

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

You can use compat.PY2

Copy link
Member

Choose a reason for hiding this comment

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

You can use compat.long (thus no need to check python ver).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified

@jreback
Copy link
Contributor

jreback commented May 5, 2016

needs a whats new with an example

@gliptak
Copy link
Contributor Author

gliptak commented May 5, 2016

added whatsnew

@gliptak
Copy link
Contributor Author

gliptak commented May 5, 2016

Please review

~~~~~~~~~~~~

Series.tolist() updated to use Python types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Copy link
Contributor

@jreback jreback May 6, 2016

Choose a reason for hiding this comment

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

make this ^^^ be the same length as the title.

Series.tolist() will now return Python types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@jreback
Copy link
Contributor

jreback commented May 7, 2016

thanks @gliptak

@jreback jreback closed this in b2009e6 May 7, 2016
@jreback jreback added this to the 0.18.2 milestone May 7, 2016
@gliptak gliptak deleted the npcompat1 branch May 10, 2016 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pandas.Series.tolist should convert Series contents from numpy datatypes to native Python datatypes
4 participants