import pandas as pd data = { 'name': ['Alice', 'Bobby', 'Carl'], 'salary': ['11.1', '12.2', '13.3'], } df = pd.DataFrame(data) df['salary'] = pd.to_numeric(df['salary']) print(df) The code sample produces the following output. output name salary 0 Alice 11.1 1 Bobb...
The best option is a space-time tradeoff, where we keep 2 copies of y - one as a Numpy array for internal use and one as a original Pandas Series. The full code for it: class FaissKNeighbors: def __init__(self, k=5): self.index = None self.y = None self._y_np = None ...
def _constant_if_small(value, shape, dtype, name): try: if np.prod(shape) < 1000: return constant(value, shape=shape, dtype=dtype, name=name) except TypeError: # Happens when shape is a Tensor, list with Tensor elements, etc. pass return None Note that you need to import reduce_p...