Skip to content

Inconsistant datatype with type()? #11969

Closed
@grgsolymosi

Description

@grgsolymosi

[in]

for cl in train.columns:
     print cl, type(train.loc[0, cl])
     print cl, type(train[cl][0])
     break

[out]

record_ID <type 'numpy.float64'> 
record_ID <type 'numpy.int64'>

Though I can solve it in many cases with train[cl].dtype, which gives the correct output:

[out]

record_ID int64

But if we work with string data types the output will be object instead of str as data type.

Something shortstop by me or what happens?
Thank you.

Activity

jreback

jreback commented on Jan 6, 2016

@jreback
Contributor

pls show train.info(), train.head() and pd.show_versions()

jorisvandenbossche

jorisvandenbossche commented on Jan 6, 2016

@jorisvandenbossche
Member

A smaller reproducible example:


In [5]: df = pd.DataFrame({'a':[0,1,2], 'b':[0.1,0.2,0.3]})

In [6]: df
Out[6]:
   a    b
0  0  0.1
1  1  0.2
2  2  0.3

In [7]: type(df.loc[0, 'a'])
Out[7]: numpy.float64

In [8]: type(df['a'][0])
Out[8]: numpy.int64
jreback

jreback commented on Jan 6, 2016

@jreback
Contributor

dupe of #11617

added this to the No action milestone on Jan 6, 2016
grgsolymosi

grgsolymosi commented on Jan 6, 2016

@grgsolymosi
Author

@jreback0
Why the "dupe" label, please?
@jorisvandenbossche 's example shows the same issue, doesn't it?

jreback

jreback commented on Jan 6, 2016

@jreback
Contributor

dupe means duplicate. See the referenced issue which is the same. We get a fair number of duplicates here (no fault of the poster of course). So try to have a single issue.

If you look at the referenced issue and it IS not the same, pls let me know.

grgsolymosi

grgsolymosi commented on Jan 6, 2016

@grgsolymosi
Author

@jreback thank you for the info and your efforts.

grgsolymosi

grgsolymosi commented on Jan 6, 2016

@grgsolymosi
Author

@jreback
Just one more info as I saw, that the other issue was on other system config:
My system:
Python 2.7.11
Ubuntu 14.04 LTS

jreback

jreback commented on Jan 6, 2016

@jreback
Contributor

@temmplar ok, these ops are not system dependent. but thanks for the info.

grgsolymosi

grgsolymosi commented on Jan 6, 2016

@grgsolymosi
Author

@jreback Furthermore I have some other additional info, which maybe would be a help to backcode the bug, if you need it, please contact me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsDuplicate ReportDuplicate issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jreback@jorisvandenbossche@grgsolymosi

        Issue actions

          Inconsistant datatype with type()? · Issue #11969 · pandas-dev/pandas