object data types

Dataframe. 1 object data type is a special data type, occurs when a column number, a string, a special character, and two kinds or more time format, object type occurs, even if the different types of split open, a still object Types of.

After following replace () function to change the data type, with astype () function and then converted to a format conversion of the object, but sometimes not.

print(train.info())
train['repay_date'] = train['repay_date'].replace("\\N",'2020-01-01')
train['repay_date'] = pd.to_datetime(train['repay_date'])
train['repay_amt'] = train['repay_amt'].replace("\\N",0)
train['repay_amt'] = train['repay_amt'].astype(float)
print(train.info())
# <class 'pandas.core.frame.DataFrame'>
# RangeIndex: 1000000 entries, 0 to 999999
# Data columns (total 7 columns):
# user_id       1000000 non-null int64
# listing_id    1000000 non-null int64
# due_date      1000000 non-null datetime64[ns]
# due_amt       1000000 non-null float64
# repay_date    1000000 non-null object
# repay_amt     1000000 non-null object
# order_id      1000000 non-null int64
# dtypes: datetime64[ns](1), float64(1), int64(3), object(2)
# memory usage: 53.4+ MB
# None
# <class 'pandas.core.frame.DataFrame'>
# RangeIndex: 1000000 entries, 0 to 999999
# Data columns (total 7 columns):
# user_id       1000000 non-null int64
# listing_id    1000000 non-null int64
# due_date      1000000 non-null datetime64[ns]
# due_amt       1000000 non-null float64
# repay_date    1000000 non-null datetime64[ns]
# repay_amt     1000000 non-null float64
# order_id      1000000 non-null int64
# dtypes: datetime64[ns](2), float64(2), int64(3)
# memory usage: 53.4 MB
# None

 

 

Guess you like

Origin www.cnblogs.com/xxswkl/p/11002954.html