<s> '''<STR_LIT>''' <EOL> __author__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> __license__ = "<STR_LIT>" <EOL> __maintainer__ = "<STR_LIT>" <EOL> __email__ = "<STR_LIT>" <EOL> __status__ = "<STR_LIT>" <EOL> import os <EOL> from pandas import DataFrame , read_csv , concat <EOL> from skspec . core . imk_utils import get_files_in_dir , get_shortname <EOL> def df_from_directory ( directory , csvargs , sortnames = False , concat_axis = <NUM_LIT:1> , shortname = True , cut_extension = False ) : <EOL> '''<STR_LIT>''' <EOL> filelist = get_files_in_dir ( directory ) <EOL> if shortname : <EOL> fget = lambda x : get_shortname ( x , cut_extension = cut_extension ) <EOL> else : <EOL> fget = lambda x : x <EOL> working_names = [ fget ( afile ) for afile in filelist ] <EOL> try : <EOL> csvargs . pop ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> pass <EOL> else : <EOL> raise Warning ( '<STR_LIT>' ) <EOL> dflist = [ read_csv ( afile , names = [ fget ( afile ) ] , ** csvargs ) for afile in filelist ] <EOL> dataframe = concat ( dflist , axis = <NUM_LIT:1> ) <EOL> if sortnames : <EOL> dataframe = dataframe . reindex ( columns = sorted ( working_names ) ) <EOL> return dataframe <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> datadirectory = '<STR_LIT>' <EOL> read_csv_args = { '<STR_LIT>' : '<STR_LIT:U+002C>' , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : '<STR_LIT>' } <EOL> df = df_from_directory ( datadirectory , read_csv_args , sortnames = True ) </s>
