1. 程式人生 > >pandas 強制型別轉換 df.astype

pandas 強制型別轉換 df.astype

import pandas as pd
from matplotlib import pyplot as plt
from datetime import datetime
filename='sitka_weather_2014.csv'



df=pd.read_csv(filename)
print(df.dtypes)

df[' Min Humidity']=df[' Min Humidity'].astype('float64')
df=df.astype({'Max Humidity':'float64','Max Dew PointF':'float64'})

print('*'*44)
print(df.dtypes)