79089852

Date: 2024-10-15 12:15:42
Score: 2.5
Natty:
Report link

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.

Reasons:
  • RegEx Blacklisted phrase (2.5): please tell me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Y. Sun