This time to everyone to bring the object format how lossless conversion to float64 format, the object format lossless conversion into the float64 format of the note, the following is the actual case, together to see.
In the process of data processing
For example, importing data from a CSV file
DATA_DF = Pd.read_csv ("Names.csv")
Be sure to look at the type of data before you process it
Data_df.info ()
*rangeindex:891 entries, 0 to 890 Data columns (total columns): Name 891 Non-null Object Sex 891 Non-null Object age 7 Non-null float64 sibsp 891 non-null Int64 parch 891 non-null Int64 Ticket 891 Non-null object Fare 891 non-null float64 Cabin 204 Non-null Object embarked 889 Non-null object Dtypes:float64 (2), Int64 (5), Object (5) Memory usage:83.6+ kb*
The above object, int64, and float64 are the types of data.
If we need to do an operation on the column data, it is important to note that:
Whether the data type of the two columns is the same!!
If an object type is added to the int64 type, an error occurs
The error message may be as follows:
Typeerror:ufunc ' Add ' not contain a loop with signature matching types Dtype (' <u32 ') dtype (' <u32 ') dtype (' <u32 ')
The type of object at this time may be ' 12.3 ' such as the number in STR format, if the operation must be formatted to convert:
The following methods can be used (convert_objects):
DT_DF = Dt_df.convert_objects (convert_numeric=true)
The pro-test is effective.
I'll remind you again! Get the data must first look at the data type!!!
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
How object is converted to float data
Vue2 How to implement bidirectional binding of parent and child components