但没有任何效果,我无法摆脱错误消息。
在此先感谢您将投入的时间帮助我,当然还有更多的人
我正在使用kaggle来运行笔记本,配置很简单,我没有加载任何库
我想舍入一列,并用结果创建一个新列
id; city.coord.lon; city.coord.lat
12957; 4.32664; 51.219791
12958; 3.33848; 50.812679
12959; 3.81052; 50.869560
# load the history city list
with open(history_city_list_path) as f:
d = json.load(f)
df_weather_in_cities = pd.json_normalize(d)
# filter the belgian cities
df_cities_weather_in_be = df_weather_in_cities[df_weather_in_cities['city.country']=='BE']
id float64
city.name object
city.coord.lon float64
city.coord.lat float64
dtype: object
df_cities_weather_in_be['lat_rounded'] = df_cities_weather_in_be.loc[:,('city.coord.lat')].apply(lambda x: np.round(x, 4))
df_cities_weather_in_be['long_rounded'] = df_cities_weather_in_be['city.coord.lat'].apply(lambda x: np.round(x, 4))
df_cities_weather_in_be.loc[:,'long_rounded'] = df_cities_weather_in_be['city.coord.lat'].apply (lambda x: np.round(x, 4))
df_cities_weather_in_be.loc[:,'long_rounded'] = np.round(df_cities_weather_in_be.loc[:,'city.coord.lat'], 4)
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
"""Entry point for launching an IPython kernel.