You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pd.TimedeltaIndex and pd.DatetimeIndex are intended for the construction of time series, with support including tshift and resample. But attempting to access tdi.data or dti.data results in "ValueError: cannot include dtype 'M' in a buffer." This is inconvenient because it makes it difficult to access the underlying numpy array, for use in operations requiring that representation, for instance for plotting spectrograms in librosa (librosa.display.specshow).
Given that a pandas.Index object is immutable, it probably suffices to construct a time series index by first creating an underlying numpy array variable, and then keeping that numpy array variable and passing it instead of the index.data wherever one might want to do the latter. But that's clunky and introduces the potential for errors.
This problem seems to arise upstream from numpy.datetime64's lack of support for buffers, though I can't say I really understand. Nevertheless I'm raising the issue here in pandas, to highlight an incompatibility between pandas' typical grammar (i.e., the Index.data attribute) and implementation of pd.DatetimeIndex and pd.TimedeltaIndex. This issue is related to Numpy issue #7270.
Code Sample, a copy-pastable example if possible
Problem description
pd.TimedeltaIndex and pd.DatetimeIndex are intended for the construction of time series, with support including tshift and resample. But attempting to access tdi.data or dti.data results in "ValueError: cannot include dtype 'M' in a buffer." This is inconvenient because it makes it difficult to access the underlying numpy array, for use in operations requiring that representation, for instance for plotting spectrograms in librosa (librosa.display.specshow).
Given that a pandas.Index object is immutable, it probably suffices to construct a time series index by first creating an underlying numpy array variable, and then keeping that numpy array variable and passing it instead of the index.data wherever one might want to do the latter. But that's clunky and introduces the potential for errors.
This problem seems to arise upstream from numpy.datetime64's lack of support for buffers, though I can't say I really understand. Nevertheless I'm raising the issue here in pandas, to highlight an incompatibility between pandas' typical grammar (i.e., the Index.data attribute) and implementation of pd.DatetimeIndex and pd.TimedeltaIndex. This issue is related to Numpy issue #7270.
Expected Output
A memory view, like
<memory at 0x1c27393288>
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: