In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to format latitude and longitude with python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. To clean up the data, it is mainly a matter of degrees, minutes and seconds, some of which are in Chinese or English, which need to be replaced by one in Excel.
2. Extract the number of degrees in minutes and seconds and deal with them separately.
Use the split function here, or the regular expression, and look at yourself, I use the regular expression here.
3. Use the format function for formatting.
For example, two bits are reserved for use: 02d.
Example
Import pandas as pdimport re df = pd.read_excel ('1.xlsxx, sheet_name =' Sheet1') def get (x): degree = re.findall ('(\ d +) °', x) [0] minute = re.findall ('°(\ d +)', x) [0] second = re.findall (''(. *?) "'' X) [0] return''{} °{: 02d}'{: 05.2f} "N'''.format (degree, int (minute), float (second)) df ['lat'] = df [' latitude'] .what are the advantages of apply (get) dfPython 1. Easy to use Compared with traditional languages such as Python, Java, C# and so on, Python has less strict requirements on code format.
2. Python is open source, everyone can see the source code, and it can be ported to many platforms.
3. Python is object-oriented, which can support both process-oriented programming and object-oriented programming.
4. Python is an interpretive language. Programs written by Python do not need to be compiled into binary code and can be run directly from the source code.
5. Python has powerful functions, has many modules, and can basically achieve all the common functions.
This is the end of "how to format latitude and longitude with python". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.