I have these 2 almost identical dataframes. But the comparison indicates that there is some difference in one of the columns.
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import pandas as pd
u_cols=['country', 'index', 'current_tm']
myst="""india, 905034 , '19.44'
USA, 905094 , '19.33'
Russia, 905154 , '21:56'
"""
df = pd.read_csv(StringIO(myst), sep=',', names = u_cols)
myst1="""india, 905034 , 19.44
USA, 905094 , '19.33'
Russia, 905154 , '21:56'
"""
ndf = pd.read_csv(StringIO(myst1), sep=',', names = u_cols)
(df==ndf).all()
country True
index True
current_tm False
dtype: bool
If I add quote to 19.44 in the second dataframe, then I will get True for all 3 columns.
Is there any other way to compare and confirm the column current_tm is the same?
Comments
Post a Comment