Make Wildcard use in names possible for stucture
SlimFrkh opened this issue · 2 comments
SlimFrkh commented
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 commented
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 commented
With v2.5.0 this issue should be resolved. Please let me know if you encounter any problems still.