Skip to content

Commit

Permalink
code sample for pandas-dev#46306
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins committed Mar 12, 2022
1 parent a3c8836 commit f35ceca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bisect/46306.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# BUG: replace method with np.nan produces incorrect results #46306

import numpy as np
import pandas as pd

print(pd.__version__)

df = pd.DataFrame({"A": [0, 1, 2], "B": [1, 0, 2]})
result = df.replace({0: 1, 1: np.nan})
print(result)

expected = pd.DataFrame({"A": [1.0, np.nan, 2.0], "B": [np.nan, 1.0, 2.0]})
pd.testing.assert_frame_equal(result, expected)

0 comments on commit f35ceca

Please sign in to comment.