A more concise way is either
import pandas as pd
def csv_to_df(path: str) -> pd.DataFrame:
return pd.read_csv(path, skiprows=1, sep='\t', comment='#')
# as for param type hint
def handle_df(df:pd.DataFrame):
pass
or
import pandas as pd
from pandas import DataFrame
def csv_to_df(path: str) -> DataFrame:
return pd.read_csv(path, skiprows=1, sep='\t', comment='#')
# as for param type hint
def handle_df(df:DataFrame):
pass
But the draw back of this kind of type hint is that you can not add the constraint of the column names and column types.
I am seeking for the solutions. If anyone knowns please tell me.