Skip to content

Minor change: reset dataframe index for input data - #762

Merged
Japhiolite merged 1 commit into
gempy-project:mainfrom
adamchengtkc:master
Mar 22, 2023
Merged

Japhiolite merged 1 commit into
gempy-project:mainfrom
adamchengtkc:master

Conversation

@adamchengtkc

Copy link
Copy Markdown
Contributor

Description

Reset input Pandas df index when loading dataframe from init_data()

Currently if loading data from dataframe which has duplicated index, pandas will return indexing error. This fix indexing and make copy of the input dataframe (To maintain immutability of user input data)

Checklist

  • [x ] My code follows the PEP 8 style guidelines.
  • [n/a] My code uses type hinting for function and method arguments and return values.
  • [n/a] My code contains descriptive and helpful docstrings
    which are formatted per the Google Python Style Guidelines.
  • [n/a] I have created tests which entirely cover my code.
  • [n/a] The test code either 1. demonstrates at least one valuable use case (e.g. integration tests)
    or 2. verifies that outputs are as expected for given inputs (e.g. unit tests).
  • [n/a] New and existing tests pass locally with my changes.

@AlexanderJuestel

Copy link
Copy Markdown
Contributor

@adamchengtkc, that is a nice addition to GemPy. I avoided fixing the error that you experiencing to make sure that the user resets the index before passing the data to GemPy.

@adamchengtkc

adamchengtkc commented Feb 23, 2023

Copy link
Copy Markdown
Contributor Author

Yep that can also work. But I would add catching the indexing error from Pandas and provide more explicit error message to the user on ways to fixing their code

Feel free to close this without merge

@Japhiolite
Japhiolite merged commit af31150 into gempy-project:main Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants