diff --git a/altair/utils/tests/test_utils.py b/altair/utils/tests/test_utils.py index 100e24154..4446e46e8 100644 --- a/altair/utils/tests/test_utils.py +++ b/altair/utils/tests/test_utils.py @@ -43,10 +43,10 @@ def test_sanitize_dataframe(): 'o': pd.Series([np.array(i) for i in range(5)])}) # add some nulls - df.ix[0, 's'] = None - df.ix[0, 'f'] = np.nan - df.ix[0, 'd'] = pd.NaT - df.ix[0, 'o'] = np.array(np.nan) + df.iloc[0, df.columns.get_loc('s')] = None + df.iloc[0, df.columns.get_loc('f')] = np.nan + df.iloc[0, df.columns.get_loc('d')] = pd.NaT + df.iloc[0, df.columns.get_loc('o')] = np.array(np.nan) # JSON serialize. This will fail on non-sanitized dataframes df_clean = sanitize_dataframe(df) @@ -55,6 +55,9 @@ def test_sanitize_dataframe(): # Re-construct pandas dataframe df2 = pd.read_json(s) + # Re-order the columns to match df + df2 = df2[df.columns] + # Re-apply original types for col in df: if str(df[col].dtype).startswith('datetime'): @@ -65,5 +68,5 @@ def test_sanitize_dataframe(): df2[col] = df2[col].astype(df[col].dtype) # pandas doesn't properly recognize np.array(np.nan), so change it here - df.ix[0, 'o'] = np.nan + df.iloc[0, df.columns.get_loc('o')] = np.nan assert df.equals(df2) diff --git a/altair/vegalite/v2/examples/select_detail.py b/altair/vegalite/v2/examples/select_detail.py index 84bb62c80..2fe397a08 100644 --- a/altair/vegalite/v2/examples/select_detail.py +++ b/altair/vegalite/v2/examples/select_detail.py @@ -36,6 +36,7 @@ timeseries = timeseries.reset_index().melt('time') # Merge the (x, y) metadata into the long-form view +timeseries['id'] = timeseries['id'].astype(int) # make merge not complain data = pd.merge(timeseries, locations, on='id') # Data is prepared, now make a chart