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

[BUG] Crashing on integer conversion on MetCouncil network writeout #132

Open
3 tasks
e-lo opened this issue Mar 17, 2022 · 1 comment
Open
3 tasks

[BUG] Crashing on integer conversion on MetCouncil network writeout #132

e-lo opened this issue Mar 17, 2022 · 1 comment
Assignees
Labels
fix Something isn't working/bug fix

Comments

@e-lo
Copy link
Collaborator

e-lo commented Mar 17, 2022

Describe the bug

Failing to convert to integer on writing out

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Failing tests

  • No applicable test failed, need to create.
  • [ ]

Triggering line of code

Thoughts on resolution

  • Do some more try/excepts and also add better logging.
  • Add in logging.

Full stack trace

2022-02-25 11:24:58, INFO: Converting variable type to MetCouncil standard

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

c:\lasso\lasso\roadway.py in convert_int(self, int_col_names)

   1116                 self.links_df[c] = self.links_df[c].replace(np.nan, 0)

-> 1117                 self.links_df[c] = self.links_df[c].astype(int)

   1118             except:

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\generic.py in astype(self, dtype, copy, errors)

   5697             # else, only a single dtype is given

-> 5698             new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors)

   5699             return self._constructor(new_data).__finalize__(self)

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\internals\managers.py in astype(self, dtype, copy, errors)

    581     def astype(self, dtype, copy: bool = False, errors: str = "raise"):

--> 582         return self.apply("astype", dtype=dtype, copy=copy, errors=errors)

    583

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\internals\managers.py in apply(self, f, filter, **kwargs)

    441             else:

--> 442                 applied = getattr(b, f)(**kwargs)

    443             result_blocks = _extend_blocks(applied, result_blocks)

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\internals\blocks.py in astype(self, dtype, copy, errors)

    624             try:

--> 625                 values = astype_nansafe(vals1d, dtype, copy=True)

    626             except (ValueError, TypeError):

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\dtypes\cast.py in astype_nansafe(arr, dtype, copy, skipna)

    873         if np.issubdtype(dtype.type, np.integer):

--> 874             return lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)

    875

 

pandas\_libs\lib.pyx in pandas._libs.lib.astype_intsafe()

 

ValueError: invalid literal for int() with base 10: ''

 

During handling of the above exception, another exception occurred:

 

ValueError                                Traceback (most recent call last)

<ipython-input-81-0e2b6783f220> in <module>

----> 1 m_net.roadway_standard_to_met_council_network()

 

c:\lasso\lasso\roadway.py in roadway_standard_to_met_council_network(self, output_epsg)

   1190         WranglerLogger.info("Splitting variables by time period and category")

   1191         self.split_properties_by_time_period_and_category()

-> 1192         self.convert_int()

   1193

   1194         self.links_metcouncil_df = self.links_df.copy()

 

c:\lasso\lasso\roadway.py in convert_int(self, int_col_names)

   1117                 self.links_df[c] = self.links_df[c].astype(int)

   1118             except:

-> 1119                 self.links_df[c] = self.links_df[c].astype(float)

   1120                 self.links_df[c] = self.links_df[c].astype(int)

   1121

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\generic.py in astype(self, dtype, copy, errors)

   5696         else:

   5697             # else, only a single dtype is given

-> 5698             new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors)

   5699             return self._constructor(new_data).__finalize__(self)

   5700

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\internals\managers.py in astype(self, dtype, copy, errors)

    580

    581     def astype(self, dtype, copy: bool = False, errors: str = "raise"):

--> 582         return self.apply("astype", dtype=dtype, copy=copy, errors=errors)

    583

    584     def convert(self, **kwargs):

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\internals\managers.py in apply(self, f, filter, **kwargs)

    440                 applied = b.apply(f, **kwargs)

    441             else:

--> 442                 applied = getattr(b, f)(**kwargs)

    443             result_blocks = _extend_blocks(applied, result_blocks)

    444

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\internals\blocks.py in astype(self, dtype, copy, errors)

    623             vals1d = values.ravel()

    624             try:

--> 625                 values = astype_nansafe(vals1d, dtype, copy=True)

    626             except (ValueError, TypeError):

    627                 # e.g. astype_nansafe can fail on object-dtype of strings

 

c:\programdata\anaconda3\envs\lasso_env\lib\site-packages\pandas\core\dtypes\cast.py in astype_nansafe

Environment

Operating system:
Context (conda, jupyter, etc):
Environment (e.g. output from conda list):

@e-lo e-lo added the fix Something isn't working/bug fix label Mar 17, 2022
@e-lo e-lo self-assigned this Mar 17, 2022
@e-lo
Copy link
Collaborator Author

e-lo commented Apr 4, 2022

@RachelWikenMC @DavidOry did this PR fix this issue for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Something isn't working/bug fix
Projects
None yet
Development

No branches or pull requests

1 participant