2020
09-27
09-27
pandas 强制类型转换 df.astype实例
废话不多说,大家还是直接看代码吧!importpandasaspdfrommatplotlibimportpyplotaspltfromdatetimeimportdatetimefilename='sitka_weather_2014.csv'df=pd.read_csv(filename)print(df.dtypes)df['MinHumidity']=df['MinHumidity'].astype('float64')df=df.astype({'MaxHumidity':'float64','MaxDewPointF':'float64'})print('*'*44)print(df.dtypes)补充知识:pythonpandas转换数据类型astype(int)报错问题代...
继续阅读 >