19 August 2020
Code
# Import library
import pandas as pd
# Create a DataFrame
df = pd.DataFrame({
'process': ['grinding', 'winding', 'milling'],
'value(float)': [22.1234, 34.4987, 54.9999]
})
print(df)
process value(float)
0 grinding 22.1234
1 winding 34.4987
2 milling 54.9999
.
# Change dtype of column
df['new_value(integer)'] = df['value(float)'].astype('int64')
# Output
print(df)
Output:
process value(float) new_value(integer)
0 grinding 22.1234 22
1 winding 34.4987 34
2 milling 54.9999 54
Any errors in code above?
Please send a message.