-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
561 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
import pandas | ||
|
||
def format_table(data: pandas.DataFrame, titles: list, line_maker, column_def=None) -> str: | ||
if column_def is None: | ||
column_def = ['X[c]'] * len(titles) | ||
column_def[0] = '>{\\bfseries}l' | ||
|
||
r = '\\begin{{tblr}}{{{}}}\n\\hline\n'.format(''.join(column_def)) | ||
|
||
# titles | ||
r += ' & '.join(titles) + '\\\\\n\\hline\n' | ||
|
||
# data | ||
for row in data.iterrows(): | ||
r += ' & '.join(line_maker(row[1])) + '\\\\\n' | ||
|
||
r += '\\hline\n\\end{tblr}' | ||
|
||
return r | ||
|
||
def format_longtable(data: pandas.DataFrame, titles: list, line_maker, column_def=None) -> str: | ||
if column_def is None: | ||
column_def = ['X[c]'] * len(titles) | ||
column_def[0] = '>{\\bfseries}l' | ||
|
||
r = '\\begin{{longtblr}}[caption={{}}]{{colspec={{{}}}, width = 0.85\\linewidth,rowhead=1}}\n\\hline\n'.format(''.join(column_def)) | ||
|
||
# titles | ||
r += ' & '.join(titles) + '\\\\\n\\hline\n' | ||
|
||
# data | ||
for row in data.iterrows(): | ||
r += ' & '.join(line_maker(row[1])) + '\\\\\n' | ||
|
||
r += '\\hline\n\\end{longtblr}\n' | ||
|
||
return r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.