Skip to content

Instantly share code, notes, and snippets.

@joshdevins
Last active November 19, 2019 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshdevins/5fe7be187dfa55922322b88d6bd56d80 to your computer and use it in GitHub Desktop.
Save joshdevins/5fe7be187dfa55922322b88d6bd56d80 to your computer and use it in GitHub Desktop.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
700 type_pprinters=self.type_printers,
701 deferred_pprinters=self.deferred_printers)
--> 702 printer.pretty(obj)
703 printer.flush()
704 return stream.getvalue()
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/IPython/lib/pretty.py in pretty(self, obj)
400 if cls is not object \
401 and callable(cls.__dict__.get('__repr__')):
--> 402 return _repr_pprint(obj, self, cycle)
403
404 return _default_pprint(obj, self, cycle)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
695 """A pprint that just redirects to the normal repr function."""
696 # Find newlines and replace them with p.break_()
--> 697 output = repr(obj)
698 for idx,output_line in enumerate(output.splitlines()):
699 if idx:
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/dataframe.py in __repr__(self)
271
272 self.to_string(buf=buf, max_rows=max_rows, max_cols=max_cols,
--> 273 line_width=width, show_dimensions=show_dimensions)
274
275 return buf.getvalue()
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/dataframe.py in to_string(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, max_rows, max_cols, show_dimensions, decimal, line_width)
642
643 # Create a slightly bigger dataframe than display
--> 644 df = self._build_repr_df(max_rows + 1, max_cols)
645
646 if buf is not None:
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/ndframe.py in _build_repr_df(self, num_rows, num_cols)
118 tail_rows = num_rows - head_rows
119
--> 120 head = self.head(head_rows)._to_pandas()
121 tail = self.tail(tail_rows)._to_pandas()
122
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/dataframe.py in _to_pandas(self)
821 pandas.DataFrame
822 """
--> 823 return self._query_compiler.to_pandas()
824
825 def _empty_pd_df(self):
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/query_compiler.py in to_pandas(self)
338 Pandas DataFrame
339 """
--> 340 return self._operations.to_pandas(self)
341
342 # To CSV
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/operations.py in to_pandas(self, query_compiler)
456 collector = PandasDataFrameCollector()
457
--> 458 self._es_results(query_compiler, collector)
459
460 return collector.df
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/operations.py in _es_results(self, query_compiler, collector)
531 break
532 else:
--> 533 partial_result, df = query_compiler._es_results_to_pandas(es_results)
534 df = self._apply_df_post_processing(df, post_processing)
535 collector.collect(df)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/query_compiler.py in _es_results_to_pandas(self, results, batch_size)
221 is_source_field, pd_dtype = self._mappings.source_field_pd_dtype(missing)
222 df[missing] = None
--> 223 df[missing].astype(pd_dtype)
224
225 # Sort columns in mapping order
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/generic.py in astype(self, dtype, copy, errors, **kwargs)
5880 # else, only a single dtype is given
5881 new_data = self._data.astype(
-> 5882 dtype=dtype, copy=copy, errors=errors, **kwargs
5883 )
5884 return self._constructor(new_data).__finalize__(self)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/managers.py in astype(self, dtype, **kwargs)
579
580 def astype(self, dtype, **kwargs):
--> 581 return self.apply("astype", dtype=dtype, **kwargs)
582
583 def convert(self, **kwargs):
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/managers.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
436 kwargs[k] = obj.reindex(b_items, axis=axis, copy=align_copy)
437
--> 438 applied = getattr(b, f)(**kwargs)
439 result_blocks = _extend_blocks(applied, result_blocks)
440
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/blocks.py in astype(self, dtype, copy, errors, values, **kwargs)
557
558 def astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
--> 559 return self._astype(dtype, copy=copy, errors=errors, values=values, **kwargs)
560
561 def _astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/blocks.py in _astype(self, dtype, copy, errors, values, **kwargs)
641 # _astype_nansafe works fine with 1-d only
642 vals1d = values.ravel()
--> 643 values = astype_nansafe(vals1d, dtype, copy=True, **kwargs)
644
645 # TODO(extension)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/dtypes/cast.py in astype_nansafe(arr, dtype, copy, skipna)
705 # work around NumPy brokenness, #1987
706 if np.issubdtype(dtype.type, np.integer):
--> 707 return lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)
708
709 # if we have a datetime/timedelta array of objects
pandas/_libs/lib.pyx in pandas._libs.lib.astype_intsafe()
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
343 method = get_real_method(obj, self.print_method)
344 if method is not None:
--> 345 return method()
346 return None
347 else:
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/dataframe.py in _repr_html_(self)
306 return self.to_html(max_rows=max_rows, max_cols=max_cols,
307 show_dimensions=show_dimensions, notebook=True,
--> 308 bold_rows=False) # set for consistency with pandas output
309 else:
310 return None
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/dataframe.py in to_html(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, max_rows, max_cols, show_dimensions, decimal, bold_rows, classes, escape, notebook, border, table_id, render_links)
582
583 # Create a slightly bigger dataframe than display
--> 584 df = self._build_repr_df(max_rows + 1, max_cols)
585
586 if buf is not None:
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/ndframe.py in _build_repr_df(self, num_rows, num_cols)
118 tail_rows = num_rows - head_rows
119
--> 120 head = self.head(head_rows)._to_pandas()
121 tail = self.tail(tail_rows)._to_pandas()
122
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/dataframe.py in _to_pandas(self)
821 pandas.DataFrame
822 """
--> 823 return self._query_compiler.to_pandas()
824
825 def _empty_pd_df(self):
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/query_compiler.py in to_pandas(self)
338 Pandas DataFrame
339 """
--> 340 return self._operations.to_pandas(self)
341
342 # To CSV
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/operations.py in to_pandas(self, query_compiler)
456 collector = PandasDataFrameCollector()
457
--> 458 self._es_results(query_compiler, collector)
459
460 return collector.df
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/operations.py in _es_results(self, query_compiler, collector)
531 break
532 else:
--> 533 partial_result, df = query_compiler._es_results_to_pandas(es_results)
534 df = self._apply_df_post_processing(df, post_processing)
535 collector.collect(df)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/eland/query_compiler.py in _es_results_to_pandas(self, results, batch_size)
221 is_source_field, pd_dtype = self._mappings.source_field_pd_dtype(missing)
222 df[missing] = None
--> 223 df[missing].astype(pd_dtype)
224
225 # Sort columns in mapping order
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/generic.py in astype(self, dtype, copy, errors, **kwargs)
5880 # else, only a single dtype is given
5881 new_data = self._data.astype(
-> 5882 dtype=dtype, copy=copy, errors=errors, **kwargs
5883 )
5884 return self._constructor(new_data).__finalize__(self)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/managers.py in astype(self, dtype, **kwargs)
579
580 def astype(self, dtype, **kwargs):
--> 581 return self.apply("astype", dtype=dtype, **kwargs)
582
583 def convert(self, **kwargs):
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/managers.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
436 kwargs[k] = obj.reindex(b_items, axis=axis, copy=align_copy)
437
--> 438 applied = getattr(b, f)(**kwargs)
439 result_blocks = _extend_blocks(applied, result_blocks)
440
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/blocks.py in astype(self, dtype, copy, errors, values, **kwargs)
557
558 def astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
--> 559 return self._astype(dtype, copy=copy, errors=errors, values=values, **kwargs)
560
561 def _astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/internals/blocks.py in _astype(self, dtype, copy, errors, values, **kwargs)
641 # _astype_nansafe works fine with 1-d only
642 vals1d = values.ravel()
--> 643 values = astype_nansafe(vals1d, dtype, copy=True, **kwargs)
644
645 # TODO(extension)
~/Documents/source/elastic/ml-search/tools/universal/metrics/venv/lib/python3.7/site-packages/pandas/core/dtypes/cast.py in astype_nansafe(arr, dtype, copy, skipna)
705 # work around NumPy brokenness, #1987
706 if np.issubdtype(dtype.type, np.integer):
--> 707 return lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)
708
709 # if we have a datetime/timedelta array of objects
pandas/_libs/lib.pyx in pandas._libs.lib.astype_intsafe()
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment