question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feather doesn't support a dataframe column of datetime.date objects in Python

See original GitHub issue

I tried writing out a pandas dataframe to feather, and noticed that my column of datetime.date objects was producing the following error:

FeatherError                              Traceback (most recent call last)
<ipython-input-16-b9e7dd094217> in <module>()
----> 1 feather.write_dataframe(df, 'df.feather')

/Users/matthew/anaconda/lib/python2.7/site-packages/feather/api.pyc in write_dataframe(df, path)
     35             name = str(name)
     36 
---> 37         writer.write_array(name, col)
     38 
     39     writer.close()

/Users/matthew/anaconda/lib/python2.7/site-packages/feather/ext.pyx in feather.ext.FeatherWriter.write_array (feather/ext.cpp:2127)()
     86             self.write_timestamp(name, col, mask)
     87         else:
---> 88             self.write_primitive(name, col, mask)
     89 
     90     cdef write_category(self, name, col, mask):

/Users/matthew/anaconda/lib/python2.7/site-packages/feather/ext.pyx in feather.ext.FeatherWriter.write_primitive (feather/ext.cpp:2432)()
    108 
    109         col_values = _unbox_series(col)
--> 110         self.write_ndarray(col_values, mask, &values)
    111         check_status(self.writer.get().AppendPlain(c_name, values))
    112 

/Users/matthew/anaconda/lib/python2.7/site-packages/feather/ext.pyx in feather.ext.FeatherWriter.write_ndarray (feather/ext.cpp:2739)()
    133     cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1:
    134         if mask is None:
--> 135             check_status(pandas_to_primitive(values, out))
    136         else:
    137             check_status(pandas_masked_to_primitive(values, mask, out))

/Users/matthew/anaconda/lib/python2.7/site-packages/feather/ext.pyx in feather.ext.check_status (feather/ext.cpp:1543)()
     52 
     53     cdef string c_message = status.ToString()
---> 54     raise FeatherError(frombytes(c_message))
     55 
     56 set_numpy_nan(np.nan)

FeatherError: Invalid: unhandled python type, index 0 

I’m going to look to using pandas timestamps in the interim.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
wesmcommented, Apr 10, 2020

This is supported in Feather V2 (coming in pyarrow / Arrow 0.17.0)

3reactions
ben519commented, May 27, 2016

Experiencing similar pain with this issue. In my case I’m processing a large file using R, writing the result to a feather file and trying to read the file using Python. The dataset contains a Date type column which is generating an error when I try to read the file in Python (but not in R).

R Code

library(feather)
df <- data.frame(X=as.Date(c("2013-1-1", "2014-1-1", "2015-1-1")))
write_feather(df, "df.feather")
read_feather("df.feather")  # works

Python Code

import feather
feather.read_dataframe('df.feather')  # error

Error Message

NotImplementedErrorTraceback (most recent call last)
<ipython-input-39-4dfedb41c631> in <module>()
----> 1 feather.read_dataframe('df.feather')

//anaconda/envs/datasci/lib/python3.5/site-packages/feather/api.py in read_dataframe(path, columns)
     54     names = []
     55     for i in range(reader.num_columns):
---> 56         name, arr = reader.read_array(i)
     57         data[name] = arr
     58         names.append(name)

//anaconda/envs/datasci/lib/python3.5/site-packages/feather/ext.pyx in feather.ext.FeatherReader.read_array (feather/ext.cpp:3448)()

NotImplementedError: 3
Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas data format to preserve DateTimeIndex - Stack Overflow
Feather defines its own simplified schemas and metadata for on-disk representation. Feather currently supports the following column types: A ...
Read more >
Pandas for time series data — tricks and tips - Adrian G
Split a dataframe based on a date in a datetime column ... Calculate a delta between datetimes in rows (assuming index is datetime)...
Read more >
Working with datetime in Pandas DataFrame | by B. Chen
In this article, we will cover the following common datetime problems and should help you get started with data analysis. Convert strings to ......
Read more >
Super Fast Cross-Platform Data I/O with Feather - Robot Wealth
Here I've created a pandas data frame with one million rows and ten columns. Here's how long it took to write that data...
Read more >
Time series / date functionality — pandas 1.5.2 documentation
pandas supports converting integer or float epoch times to Timestamp and DatetimeIndex . The default unit is nanoseconds, since that is how Timestamp...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found