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

Make Wildcard use in names possible for stucture #100

Closed
SlimFrkh opened this issue Jan 18, 2023 · 2 comments · Fixed by #101
Closed

Make Wildcard use in names possible for stucture #100

SlimFrkh opened this issue Jan 18, 2023 · 2 comments · Fixed by #101

Comments

@SlimFrkh
Copy link

SlimFrkh commented Jan 18, 2023

Today, we can't type describe some structrure partially. for example, col a and b are ints + I don't care about other columns.
Example function:

def add_a_col_in_df(df):
    df["new_col"] = df["a"] + df["b"]
    return df

with wildcard on colnames we would make type hints like follows:

from nptyping import DataFrame
from nptyping import Structure as S

def add_a_col_in_df(df : DataFrame[S["[a, b]: Int, *: Any"]]) -> DataFrame[S["[a, b, new_col]: Int, *: Any"]]:
    df["new_col"] = df["a"] + df["b"]
    return df
@ramonhagenaars
Copy link
Owner

There is a release 2.5.0 in the making that will include this.
The syntax will be as follows:

from nptyping import DataFrame, Structure as S

DataFrame[S["[a, b]: Int, *"]]  # <-- a DataFrame with AT LEAST int columns a and b

@ramonhagenaars
Copy link
Owner

With v2.5.0 this issue should be resolved. Please let me know if you encounter any problems still.

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 a pull request may close this issue.

2 participants