程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

python tabular data grouping

編輯:Python
Just learning python, encounteringTo a question like this: Group the data in the table below, according to the historical storm_number on the left, and group those with the same number into a group.Lines 1 to 8 are grouped into a group, lines 9 to 15 are grouped into a group, and lines 16 to 22 are grouped into a group.Using pandas to read, Num is all numbers, Lon is all longitudes, and Lat is all latitudes.

df=pd.read_excel(filename,sheet_name='Sheet1')
Num = df['historical storm_number']
Lon = df['historical storm_longitude(°)']
Lat = df['historical storm_latitude(°)']

The result I want to achieve: It can be divided into Num1, Num2, Num3 according to the different numbers, the corresponding Lon is also divided into Lon1, Lon2, Lon3, and Lat is also divided into Lat1, Lat2, Lat3

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved