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

datetime64 bug arising in Series.set_value #1561

Closed
wesm opened this Issue Jul 3, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@wesm
Member

wesm commented Jul 3, 2012

from the mailing list

Hi guys,
I am using the new release 0.8.0. Below is what I observed. My numpy
version if 1.6.2. Please help. thx.

In [3]: from pandas import Series

In [4]: from datetime import datetime

In [5]: s = Series().set_value(datetime(2001,1,1),
1.).set_value(datetime(2001,1,2),float('nan'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/yihao/YH_Backups/YH_Work/lyh/gss/python/gss_main/<ipython-input-5-5c2e9c89865a>
in <module>()
----> 1 s = Series().set_value(datetime(2001,1,1),
1.).set_value(datetime(2001,1,2),float('nan'))

/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in
set_value(self, label, value)
    741             return self
    742         except KeyError:
--> 743             new_index = np.concatenate([self.index.values, [label]])
    744             new_values = np.concatenate([self.values, [value]])
    745             return Series(new_values, index=new_index, name=self.name)

TypeError: invalid type promotion
@tbekolay

This comment has been minimized.

Show comment
Hide comment
@tbekolay

tbekolay Jul 3, 2012

When I try this, I get no error and this as output:

In [1]: from pandas import Series

In [2]: from datetime import datetime

In [3]: s = Series().set_value(datetime(2001,1,1),1.).set_value(datetime(2001,1,2),float('nan'))

In [4]: s
Out[4]: 
978307200000000000      1
2001-01-02 00:00:00   NaN

I'm using the latest pandas and numpy. Looks like something is up with setting the first label in an index.

tbekolay commented Jul 3, 2012

When I try this, I get no error and this as output:

In [1]: from pandas import Series

In [2]: from datetime import datetime

In [3]: s = Series().set_value(datetime(2001,1,1),1.).set_value(datetime(2001,1,2),float('nan'))

In [4]: s
Out[4]: 
978307200000000000      1
2001-01-02 00:00:00   NaN

I'm using the latest pandas and numpy. Looks like something is up with setting the first label in an index.

@wesm

This comment has been minimized.

Show comment
Hide comment
@wesm

wesm Jul 3, 2012

Member

You must be using NumPy 1.7dev. On NumPy 1.6 numpy.concatenate has a bug with the datetime64 dtype

Member

wesm commented Jul 3, 2012

You must be using NumPy 1.7dev. On NumPy 1.6 numpy.concatenate has a bug with the datetime64 dtype

@tbekolay

This comment has been minimized.

Show comment
Hide comment
@tbekolay

tbekolay Jul 3, 2012

I am, yeah. Does it still? The first row isn't a datetime

tbekolay commented Jul 3, 2012

I am, yeah. Does it still? The first row isn't a datetime

@wesm

This comment has been minimized.

Show comment
Hide comment
@wesm

wesm Jul 3, 2012

Member

The bug is manifesting in a different way on 1.7

Member

wesm commented Jul 3, 2012

The bug is manifesting in a different way on 1.7

@ghost ghost assigned wesm Jul 11, 2012

@wesm wesm closed this in 005b264 Jul 11, 2012

@wesm

This comment has been minimized.

Show comment
Hide comment
@wesm

wesm Jul 11, 2012

Member

Fixed this in git master

Member

wesm commented Jul 11, 2012

Fixed this in git master

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