Skip to content

Commit

Permalink
Fix for newer numpy versions (#657)
Browse files Browse the repository at this point in the history
* Fix tests

* Fix pbutils

* lint

* Revert import change
  • Loading branch information
gtopper authored Jan 4, 2024
1 parent 87a7334 commit 1c7efe5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clients/py/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def compare_dfs(df1, df2, backend):
col2 = df2[name].sort_index()
assert len(col1) == len(col2), \
'{}: column {} size mismatch'.format(backend, name)
if col1.dtype == np.float:
if col1.dtype == float:
ok = np.allclose(col1.values, col2.values)
else:
ok = col1.equals(col2)
Expand Down
2 changes: 1 addition & 1 deletion clients/py/tests/test_pbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_encode_df():

df = pd.read_csv('{}/weather.csv'.format(here))
df['STATION_CAT'] = df['STATION'].astype('category')
df['WDF2_F'] = df['WDF2'].astype(np.float)
df['WDF2_F'] = df['WDF2'].astype(float)
msg = pbutils.df2msg(df, labels)

names = [col.name for col in msg.columns]
Expand Down
8 changes: 4 additions & 4 deletions clients/py/v3io_frames/pbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def series2col_with_dtype(s, name, dtype):
elif dtype == fpb.FLOAT:
kw['dtype'] = fpb.FLOAT
kw['floats'] = s
elif dtype == fpb.STRING: # Pandas dtype for str is object
elif dtype == fpb.STRING:
kw['strings'] = s
kw['dtype'] = fpb.STRING
elif dtype == fpb.BOOLEAN:
Expand Down Expand Up @@ -263,7 +263,7 @@ def series2col(s, name):
elif is_float(s.dtype):
kw['dtype'] = fpb.FLOAT
kw['floats'] = s
elif s.dtype == np.object: # Pandas dtype for str is object
elif s.dtype == object:
kw['strings'] = s
kw['dtype'] = fpb.STRING
elif is_bool(s.dtype):
Expand All @@ -278,7 +278,7 @@ def series2col(s, name):
kw['times'] = s.astype(np.int64)
kw['dtype'] = fpb.TIME
elif is_categorical_dtype(s.dtype):
# We assume catgorical data is strings
# We assume categorical data is strings
kw['strings'] = s.astype(str)
kw['dtype'] = fpb.STRING
else:
Expand All @@ -297,7 +297,7 @@ def insert_nulls_based_on_null_values_map(df, null_values):
for col_name in null_values[i].nullColumns:
# boolean columns should be converted to `object` to be able to
# represent None.
if df[col_name].dtype == np.bool and \
if df[col_name].dtype == bool and \
col_name not in casted_columns:
casted_columns[col_name] = True
df[col_name] = df[col_name].astype(object)
Expand Down

0 comments on commit 1c7efe5

Please sign in to comment.