alex_bn_lee

导航

随笔分类 -  Python Study

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 31 下一页

Study of Python.
【864】pandas dataframe根据规则批量赋值
摘要: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() 阅读全文

posted @ 2023-07-20 14:10 McDelfino 阅读(259) 评论(0) 推荐(0)

【863】Calculate records based on the same value
摘要: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 阅读全文

posted @ 2023-07-20 13:33 McDelfino 阅读(11) 评论(0) 推荐(0)

【855】country converter, ISO alpha 3
摘要: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 阅读全文

posted @ 2023-07-09 11:12 McDelfino 阅读(19) 评论(0) 推荐(0)

【853】numpy里面替换值
摘要:参考: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 阅读全文

posted @ 2023-07-06 07:48 McDelfino 阅读(74) 评论(0) 推荐(0)

【850】numpy处理日期数据
摘要:参考:Add Months to datetime Object in Python ☀☀☀<< 举例 >>☀☀☀ # import packages import pandas as pd # adding months to a particular date present = '2022-0 阅读全文

posted @ 2023-07-03 10:42 McDelfino 阅读(27) 评论(0) 推荐(0)

【847】create geoDataFrame from dataframe
摘要: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 阅读全文

posted @ 2023-06-30 08:54 McDelfino 阅读(24) 评论(0) 推荐(0)

【846】自定义cmap,用于GeoPandas、matplotlib制图
摘要:参考:自定义颜色条教程 import matplotlib as mpl cmap = mpl.colors.ListedColormap(['yellow', '#E0E0E0']) africa_gdf.plot(column='hotspot_category', cmap=cmap, leg 阅读全文

posted @ 2023-06-30 08:38 McDelfino 阅读(95) 评论(0) 推荐(0)

【843】dataframe相关操作 (match merge)
摘要:Reference: Python for Data Analysis, 3E - Pandas pandas.DataFrame.merge 29-April-2024 use to_string() to print the entire DataFrame. Check the number 阅读全文

posted @ 2023-06-15 18:31 McDelfino 阅读(39) 评论(0) 推荐(0)

【842】GeoPandas设置坐标系
摘要:参考:geopandas--坐标系学习 gdf.crs = 'EPSG:4326' 阅读全文

posted @ 2023-06-15 10:44 McDelfino 阅读(47) 评论(0) 推荐(0)

【841】shapely合并多个Polygon/MultiPolygon
摘要:参考:Converting list of polygons to multipolygon using shapely? MultiPolygon -> Polygon list list(multiPoly.geoms) Polygon list -> MultiPolygon shapely. 阅读全文

posted @ 2023-06-13 18:54 McDelfino 阅读(768) 评论(0) 推荐(0)

【839】pandas 筛选某个值在某个列表中 isin
摘要:参考:pandas 筛选某个值在某个列表中 isin #筛选某个值在某个列表中 df = df[df['subject_1'].isin([1, 2, 13, 18, 25])] 阅读全文

posted @ 2023-06-09 15:16 McDelfino 阅读(33) 评论(0) 推荐(0)

【830】计算bearing值
摘要:参考:Formula to Find Bearing or Heading angle between two points: Latitude Longitude 计算三角函数的时候,需要将经纬度的度数转换为弧度制,最后再将计算出来的弧度制转换为角度 def bearing_lonlat(phi_ 阅读全文

posted @ 2023-04-12 10:21 McDelfino 阅读(139) 评论(0) 推荐(0)

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 31 下一页