Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow internal data function calls directly from our data class #360

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

JGSweets
Copy link
Contributor

This allows the user to directly access functions of the wrapped data inside of our data class. e.g. if the data internally is a pandas dataframe:

data = CSVData(...)  # has pandas dataframe
df_without_na= data.dropna() # will not be in place unless user specifies it

# or iterating through rows
for row in data.iterrows():
    print(row)

@JGSweets JGSweets requested a review from lettergram as a code owner July 26, 2021 18:32
@JGSweets JGSweets added Low Priority Cosmetic improvement or minor bug New Feature A feature addition not currently in the library labels Jul 26, 2021
@JGSweets JGSweets force-pushed the allow-data-methods branch from 0c07e0a to c57e155 Compare July 26, 2021 21:45
class_name = self.__class__.__name__
data_class_name = self.data.__class__.__name__
if (not f"'{class_name}' object has no attribute '{name}'"
== str(attr_error)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its seems strange to use error string for the conditional, but I'm not sure any other way to do this check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i validate it is an attribute error with the except and then validate the string, there might be a better way.


# validate will auto call the data function if it doesn't exist in
# BaseData
self.assertEqual("success", data.func1())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, did you try this with csv/pandas functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

@grant-eden grant-eden enabled auto-merge (squash) July 27, 2021 17:19
@grant-eden grant-eden merged commit ab64055 into capitalone:main Jul 27, 2021
stevensecreti pushed a commit to stevensecreti/DataProfiler that referenced this pull request Jun 15, 2022
…talone#360)

* feat: allow internal data function calls directly from our data class

* fix: error raise comment and pep8 fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low Priority Cosmetic improvement or minor bug New Feature A feature addition not currently in the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants