Created
April 21, 2025 14:43
-
-
Save kelly-sovacool/da0dc48a3bf04681db515a5fc04a1050 to your computer and use it in GitHub Desktop.
testing when pandas type-casts INF strings to np.inf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a sample <class 'str'> False | |
b inf <class 'numpy.float64'> True | |
c inf <class 'numpy.float64'> True | |
d inf <class 'numpy.float64'> True | |
e inf <class 'numpy.float64'> True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from io import StringIO | |
csv_str = """a,b,c,d,e | |
sample,INF,inf,Inf,iNf | |
""" | |
df = pd.read_csv(StringIO(csv_str)) | |
for col in df.columns: | |
val= df.loc[0,col] | |
print(col, val, type(val), val == np.inf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment