alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

随笔分类 -  Python Study

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页

Study of Python.
【875】numpy复制并扩充维度
摘要:参考:numpy复制并扩充维度 参考:记录 之 numpy扩充某一维度,并重复填充 np.expand_dims():扩充数组的维度,并且制定扩充的维度位置,用axis来指定 repeat():用来复制数组内容在指定的维度上面 transpose():用来转置数组 1.numpy.expand_di 阅读全文

posted @ 2023-09-05 08:14 McDelfino 阅读(1896) 评论(0) 推荐(0) 编辑

【873】Python读取NetCDF中的scale_factor和add_offset
摘要:参考:python中scale的用法_在netCDF4和Python中使用scale_factor和add_offset的示例? 参考代码: import netCDF4 as nc dir_path = "./2m_temperature/03_TIFF/" files = os.listdir( 阅读全文

posted @ 2023-08-26 10:24 McDelfino 阅读(190) 评论(0) 推荐(0) 编辑

【871】netCDF数据处理
摘要:参考:How to convert NetCDF to GeoTIFF? 参考:利用Python(netCDF4库)读取.nc文件(NetCDF气象数据文件)的基本操作 参考:经度转换0°-360°与-180°-180°之间的相互转换 参考:https://blog.csdn.net/weixin_ 阅读全文

posted @ 2023-08-17 15:26 McDelfino 阅读(55) 评论(0) 推荐(0) 编辑

【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 阅读(228) 评论(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 阅读(5) 评论(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 阅读(13) 评论(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 阅读(59) 评论(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 阅读(23) 评论(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 阅读(9) 评论(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 阅读(62) 评论(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 阅读(19) 评论(0) 推荐(0) 编辑

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

posted @ 2023-06-15 10:44 McDelfino 阅读(36) 评论(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 阅读(667) 评论(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 阅读(102) 评论(0) 推荐(0) 编辑

【823】Python subprocess.call() 运行 R 代码
摘要:参考:How to Use R and Python Together? Try These 2 Packages 实现功能:在 Python 代码中运行 R 文件,得到结果再在 Python 里面操作! import subprocess res = subprocess.call("Rscrip 阅读全文

posted @ 2023-03-15 18:28 McDelfino 阅读(57) 评论(0) 推荐(0) 编辑

【822】GeoPandas 绘图,专题图绘制
摘要:参考:Mapping and Plotting Tools 参考:geopandas.GeoDataFrame.plot 参考:Choosing Colormaps 参考:geopandas,用python分析地理空间数据原来这么简单! 参考:「GIS教程」Python-GeoPandas地图、专题 阅读全文

posted @ 2023-03-15 15:12 McDelfino 阅读(246) 评论(0) 推荐(0) 编辑

【820】Python R 读取 csv 文件加入数据类型控制
摘要:参考:PySe-023-pandas.read_csv 读取 csv 文件,指定列数据类型 解决字符串数据列变为数字的问题 参考:Read a delimited file (including CSV and TSV) into a tibble Python:根据具体的列名指定数据格式 impo 阅读全文

posted @ 2023-03-13 17:53 McDelfino 阅读(76) 评论(0) 推荐(0) 编辑

【818】Python dataframe 重命名列名
摘要:参考:pandas: Rename column/index names (labels) of DataFrame rename(columns={字典}) 例子: print(df.rename(columns={'A': 'Col_1', 'C': 'Col_3'})) # Col_1 B C 阅读全文

posted @ 2023-03-13 14:05 McDelfino 阅读(52) 评论(0) 推荐(0) 编辑

【817】Python dataframe 多条件筛选
摘要:参考:Pandas条件筛选并赋值实用操作一例 选择不包含以下两个值的其他内容 df_130 = df2[(df2['.region_id'] != 25025000703) & (df2['.region_id'] != 25025000504)] 阅读全文

posted @ 2023-03-13 13:57 McDelfino 阅读(142) 评论(0) 推荐(0) 编辑

【816】rpy2 在Python内部调用R语言
摘要:参考:rpy2 学习笔记 参考:在python中使用R|rpy2 阅读全文

posted @ 2023-03-13 13:43 McDelfino 阅读(21) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页
点击右上角即可分享
微信分享提示