Pythonic type hints with pandas?

后端 未结 5 1942
名媛妹妹
名媛妹妹 2020-12-24 04:36

Let\'s take a simple function that takes a str and returns a dataframe:

import pandas as pd
def csv_to_df(path):
    return pd.read_csv(path, skiprows=1, sep         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 05:06

    Now there is a pip package that can help with this. https://github.com/CedricFR/dataenforce

    You can install it with pip install dataenforce and use very pythonic type hints like:

    def preprocess(dataset: Dataset["id", "name", "location"]) -> Dataset["location", "count"]:
        pass
    

提交回复
热议问题