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: fix examples & tests for pandas 0.23 #846

Merged
merged 1 commit into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions altair/utils/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'):
Expand All @@ -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)
1 change: 1 addition & 0 deletions altair/vegalite/v2/examples/select_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down