1

I tried calculating minutes by subtracting two columns. But an error shows up which is " ValueError: unit abbreviation w/o a number". However, I tried similar operation on two different columns but it worked.

I tried calculating arr_delay, but there was no error. But error came up when I tried calculating dep_delay.

data['arr_delay'] = (pd.to_timedelta(data.ATA) - pd.to_timedelta(data.STA)).dt.total_seconds()/60 data['dep_delay'] = (pd.to_timedelta(data.ATD) - pd.to_timedelta(data.STD)).dt.total_seconds()/60 

I was able to calculate arr_delay. But an error came up while calculating dep_delay which is :-" ValueError: unit abbreviation w/o a number "

Data Sample

1 Answer 1

2

In my opinion there are some bad values in some column, so use parameter errors='coerce' for convert these values to NaT:

data['dep_delay'] = (pd.to_timedelta(data.ATD, errors='coerce') - pd.to_timedelta(data.STD, errors='coerce')).dt.total_seconds()/60 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.