Study of Python.
摘要:ref: Pandas新增一列并按条件赋值? 把下图中的 NaN 都赋值为 0 df.loc[条件判断, 'value'] = 0 m = pd.merge(gdf_africa, df_af_mp, how='left', on='country') m.loc[m['value'].isna()
阅读全文
摘要:Suppose we have a dataframe, it has a column of "country". It lists different names of country's names, and for one country maybe it has multiple reco
阅读全文
摘要:Ref: country-converter 1.0.0 Ref: Python-pycountry | Understand How to Use pycountry These two python libraries are both used to process information a
阅读全文
摘要:参考:How to Replace Elements in NumPy Array (3 Examples) You can use the following methods to replace elements in a NumPy array: Method 1: Replace Eleme
阅读全文
摘要:参考:Add Months to datetime Object in Python ☀☀☀<< 举例 >>☀☀☀ # import packages import pandas as pd # adding months to a particular date present = '2022-0
阅读全文
摘要:Ref: From WKT format Firstly, we already have a dataframe, and there is a column of geometry. But this column is in the format of the string, therefor
阅读全文
摘要:参考:自定义颜色条教程 import matplotlib as mpl cmap = mpl.colors.ListedColormap(['yellow', '#E0E0E0']) africa_gdf.plot(column='hotspot_category', cmap=cmap, leg
阅读全文
摘要:Reference: Python for Data Analysis, 3E - Pandas pandas.DataFrame.merge 29-April-2024 use to_string() to print the entire DataFrame. Check the number
阅读全文
摘要:参考:geopandas--坐标系学习 gdf.crs = 'EPSG:4326'
阅读全文
摘要:参考:Converting list of polygons to multipolygon using shapely? MultiPolygon -> Polygon list list(multiPoly.geoms) Polygon list -> MultiPolygon shapely.
阅读全文
摘要:参考:pandas 筛选某个值在某个列表中 isin #筛选某个值在某个列表中 df = df[df['subject_1'].isin([1, 2, 13, 18, 25])]
阅读全文
摘要:参考:Formula to Find Bearing or Heading angle between two points: Latitude Longitude 计算三角函数的时候,需要将经纬度的度数转换为弧度制,最后再将计算出来的弧度制转换为角度 def bearing_lonlat(phi_
阅读全文