Skip to content

API: Can't override type sniffing in df.from_csv()? #3171

Closed
@ghost

Description

In [10]: ix = [-352.737091, 183.575577]
    ...: df=pd.DataFrame([0,1],index=ix)
    ...: df.to_csv("/tmp/1.csv")
    ...: df2=pd.DataFrame.from_csv("/tmp/1.csv")
    ...: print df
    ...: print df2
             0
-352.737091  0
 183.575577  1
                            0
2105-11-21 22:43:41.128654  0
1936-11-21 22:43:41.128654  1

and if you try:


In [13]: df2.index.astype('f')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-8d8276604fe4> in <module>()
----> 1 df2.index.astype('f')

/home/user1/src/pandas/pandas/tseries/index.pyc in astype(self, dtype)
    624             return self.asi8.copy()
    625         else:  # pragma: no cover
--> 626             raise ValueError('Cannot cast DatetimeIndex to dtype %s' % dtype)
    627 
    628     @property

ValueError: Cannot cast DatetimeIndex to dtype float32

related SO

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignBugIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions