staticmethod def save_df_to_csv df pd DataFrame csv_base_name str resu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@staticmethod
def save_df_to_csv(df: pd.DataFrame,
csv_base_name: str = 'result',
need_to_add_datetime: bool = True,
is_datetime_prefix: bool = True,
sep: str = ',',
need_order_by_index: bool = True,
tac_column_name: str = 'tac',
need_to_add_apostrophe_to_tac: bool = True,
need_to_insert_index: bool = True):
try:
filename = DfWorker._generate_csv_name(
csv_base_name, need_to_add_datetime, is_datetime_prefix)
if need_order_by_index:
df.sort_index(inplace=True)
if need_to_add_apostrophe_to_tac:
df[tac_column_name] = "'" + df[tac_column_name]
df.to_csv(
filename, sep=sep, index=need_to_insert_index)
except Exception as e:
raise DfWorkerException(e)