MCPcopy Index your code
hub / github.com/ScottfreeLLC/AlphaPy / write_frame

Function write_frame

alphapy/frame.py:177–212  ·  view source on GitHub ↗

r"""Write a dataframe into a delimiter-separated file. Parameters ---------- df : pandas.DataFrame The pandas dataframe to save to a file. directory : str Full directory specification. filename : str Name of the file to write, excluding the ``extension``.

(df, directory, filename, extension, separator,
                index=False, index_label=None, columns=None)

Source from the content-addressed store, hash-verified

175#
176
177def write_frame(df, directory, filename, extension, separator,
178 index=False, index_label=None, columns=None):
179 r"""Write a dataframe into a delimiter-separated file.
180
181 Parameters
182 ----------
183 df : pandas.DataFrame
184 The pandas dataframe to save to a file.
185 directory : str
186 Full directory specification.
187 filename : str
188 Name of the file to write, excluding the ``extension``.
189 extension : str
190 File name extension, e.g., ``csv``.
191 separator : str
192 The delimiter between fields in the file.
193 index : bool, optional
194 If ``True``, write the row names (index).
195 index_label : str, optional
196 A column label for the ``index``.
197 columns : str, optional
198 A list of column names.
199
200 Returns
201 -------
202 None : None
203
204 """
205 file_only = PSEP.join([filename, extension])
206 file_all = SSEP.join([directory, file_only])
207 logger.info("Writing data frame to %s", file_all)
208 try:
209 df.to_csv(file_all, sep=separator, index=index,
210 index_label=index_label, columns=columns)
211 except:
212 logger.info("Could not write data frame to %s", file_all)
213
214
215#

Callers 7

run_analysisFunction · 0.90
training_pipelineFunction · 0.90
gen_portfolioFunction · 0.90
mainFunction · 0.90
run_systemFunction · 0.90
save_predictionsFunction · 0.90
dump_framesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected