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

BUG: datetime64[ns] conversion to object in DataFrame constructor inconsistent #2751

Closed
jreback opened this issue Jan 25, 2013 · 1 comment

Comments

@jreback
Copy link
Contributor

commented Jan 25, 2013

this seems to happend when there is an object type passed as well

In [55]: df = pd.DataFrame({'a':[1,2,4,7], 
    'b':[1.2, 2.3, 5.1, 6.3], 
    'c':list('abcd'), 
    'd':[pd.datetime(2000,1,1) for i in range(4)]})

In [56]: df
Out[56]: 
   a    b  c                    d
0  1  1.2  a  2000-01-01 00:00:00
1  2  2.3  b  2000-01-01 00:00:00
2  4  5.1  c  2000-01-01 00:00:00
3  7  6.3  d  2000-01-01 00:00:00

In [57]: df.dtypes
Out[57]: 
a      int64
b    float64
c     object
d     object

# this is ok
In [64]: df = pd.DataFrame({'a':[1,2,4,7], 'b':[1.2, 2.3, 5.1, 6.3], 'd':[pd.datetime(2000,1,1) for i in range(4)]})

In [65]: df.dtypes
Out[65]: 
a             int64
b           float64
d    datetime64[ns]

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Jan 25, 2013

closed in #2752

@jreback jreback closed this Jan 25, 2013

jreback added a commit to jreback/pandas that referenced this issue Jan 31, 2013
BUG: various bug fixes for DataFrame/Series construction related to:
        0 and 1 len ndarrays
        datetimes that are single objects
        mixed datetimes and objects (GH pandas-dev#2751)
        astype now converts correctly with a datetime64 type to object, NaT are converted to np.nan
        _get_numeric_data with empty mixed-type returning empty, but index was missing
DOC: release notes updated, added missing_data section to docs, whatsnew 0.10.2
jreback added a commit to jreback/pandas that referenced this issue Feb 13, 2013
BUG: fixup GH pandas-dev#2751; make sure that we cast to platform num…
…eric

     when a list is specified; use the Series codepath
     for initial list conversion (change from using DataFrame)
TST: added test for overflow in df creation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.