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

Not sure if this is a bug or just me misunderstanding things. #44

Closed
swedishmike opened this issue Nov 14, 2017 · 1 comment
Closed

Comments

@swedishmike
Copy link
Contributor

I tried to generate some graphs from the conn.log file when I ran into some problems.

If I follow the 'Bro_to_Plot.ipynb' framework and try the following:

conn_df['duration'].hist()

It bombs out with quite a lot of error output which culminates with:

TypeError: Cannot cast ufunc less input from dtype('float64') to dtype('<m8[ns]') with casting rule 'same_kind'

Some Googling later I tried with the following:

conn_df.duration = conn_df.duration.astype('timedelta64')

Once I did that the plot displayed properly.

I'm still very much a beginner when it comes to Pandas so I'm not sure if the problem lies in the generation of the Dataframe and the 'type assignment' or if it is something else?

@brifordwylie
Copy link
Member

brifordwylie commented Nov 20, 2017

Hi @swedishmike,

Thanks for finding this. Looking at the types of the conn_df.. I see that the type of the duration is timedelta64[ns].. which seems correct.

conn_df.dtypes
Out[10]:
conn_state                 object
duration          timedelta64[ns]
history                    object
...

I'm not a time delta expert but I found a conversion/overflow issue described here: http://www.datasciencebytes.com/bytes/2015/05/16/pandas-timedelta-histograms-unit-conversion-and-overflow-danger/

So when I convert this to a time in seconds or milliseconds, as you stated above, the plot works fine. I would definitely put in the [s] or [ms] arg to timedelta64 so that you explicitly know what you're getting.

conn_df['duration'] = conn_df['duration'].astype('timedelta64[ms]')

I'm not sure this is really a bug.. just perhaps a known issue with time deltas and plotting, so I'm going to close this. But I am going to create an issue that documents this and gives examples of plotting time deltas. (new issue is #46)

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

No branches or pull requests

2 participants