question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOC: detailing docstring and add lon & lat as args in points_from_xy()

See original GitHub issue

I’m so glad to see the gpd.points_from_xy() function in 0.5.0 . The function needs two args:

geometry = gpd.points_from_xy(df.longitude, df.latitude)
gdf = gpd.GeoDataFrame(df, geometry=geometry)

This requires the users to know the order of longitude and latitude. I wonder if they could be optional args so that the users don’t have to remember the order so either geometry = gpd.points_from_xy(lon=df.longitude, lat=df.latitude) or geometry = gpd.points_from_xy(lat=df.latitude, lon=df.longitude) works.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
jorisvandenbosschecommented, May 11, 2019

Adding it to the docstring is certainly a good idea!

Giving an error message is not really possible I think, as it is difficult to detect (most often switching lon and lat gives some location on earth, just not the one you wanted).

1reaction
martinfleiscommented, May 23, 2019

On the other hand, some people use Geopandas to handle abstract datasets where latitude and longitude doesn’t really make sense while x and y works always. Even though you have to remember which is x and which y.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Docstrings Tutorial : Examples & Format for Pydoc ...
Docstrings in Python Tutorial. Learn about Python Docstrings. Find different examples & format types of docstrings for Sphinx, Numpy and Pydoc.
Read more >
Python Docstring: Documenting And Introspecting Functions
This tutorial explains what is Python Docstring and how to use it to document Python functions with examples.
Read more >
Python Docstrings (With Examples) - Programiz
Python docstrings are the string literals that appear right after the definition of a function, method, class, or module. Let's take an example....
Read more >
pandas docstring guide — pandas 1.5.2 documentation
A Python docstring is a string used to document a Python module, class, ... each parameter in the signature must be documented, including...
Read more >
Documenting Python Code: A Complete Guide
Along with docstrings, Python also has the built-in function help() that prints out the objects docstring to the console. Here's a quick example:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found