Coverage for src/ensae_teaching_cs/automation/modules_documentation.py: 68%

22 statements  

« prev     ^ index     » next       coverage.py v7.1.0, created at 2023-01-27 05:44 +0100

1""" 

2@file 

3@brief Customize a Windows Setup for these teachings 

4""" 

5 

6import pandas 

7from pyquickhelper.pandashelper import df2rst 

8 

9 

10def rst_table_modules(classifier=False): 

11 """ 

12 Produces a table with some modules useful 

13 to do machine learning. 

14 

15 @param classifier keep classifiers? 

16 @return string 

17 """ 

18 try: 

19 from pymyinstall.packaged import small_set, classifiers2string 

20 except KeyError: 

21 from pyquickhelper.pycode.pip_helper import fix_pip_902 

22 fix_pip_902() 

23 from pymyinstall.packaged import small_set, classifiers2string 

24 mod = small_set() 

25 mod.sort() 

26 df = pandas.DataFrame(_.as_dict(rst_link=True) for _ in mod) 

27 if classifier: 

28 df = df[["usage", "rst_link", "kind", "version", 

29 "license", "purpose", "classifier"]] 

30 df["classifier"] = df.apply( 

31 lambda row: classifiers2string(row["classifier"]), axis=1) 

32 df.columns = ["usage", "name", "kind", "version", 

33 "license", "purpose", "classifier"] 

34 else: 

35 df = df[["usage", "rst_link", "kind", "version", 

36 "license", "purpose"]] 

37 df.columns = ["usage", "name", "kind", "version", 

38 "license", "purpose"] 

39 df["lname"] = df["name"].apply(lambda s: s.lower()) 

40 df = df.sort_values("lname").drop("lname", axis=1) 

41 df = df.reset_index(drop=True).reset_index(drop=False) 

42 return df2rst(df)