Python pandas.to_csv() Examples
The following are 4
code examples of pandas.to_csv().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas
, or try the search function
.
Example #1
Source File: mysql_to_s3.py From airflow with Apache License 2.0 | 6 votes |
def execute(self, context): mysql_hook = MySqlHook(mysql_conn_id=self.mysql_conn_id) s3_conn = S3Hook(aws_conn_id=self.aws_conn_id, verify=self.verify) data_df = mysql_hook.get_pandas_df(self.query) self.log.info("Data from MySQL obtained") self._fix_int_dtypes(data_df) with NamedTemporaryFile(mode='r+', suffix='.csv') as tmp_csv: data_df.to_csv(tmp_csv.name, **self.pd_csv_kwargs) s3_conn.load_file(filename=tmp_csv.name, key=self.s3_key, bucket_name=self.s3_bucket) if s3_conn.check_for_key(self.s3_key, bucket_name=self.s3_bucket): file_location = os.path.join(self.s3_bucket, self.s3_key) self.log.info("File saved correctly in %s", file_location)
Example #2
Source File: checkpandas.py From tdda with MIT License | 6 votes |
def default_csv_writer(df, csvfile, **kwargs): """ Default function for writing a csv file. Wrapper around the standard pandas pd.to_csv() function, but with slightly different defaults: - index is ``False`` - encoding is ``utf-8`` """ options = { 'index': False, 'encoding': 'utf-8', } options.update(kwargs) if sys.version_info[0] > 2 and len(df) > 0: bytes_cols = find_bytes_cols(df) if bytes_cols: df = bytes_to_unicode(df, bytes_cols) return df.to_csv(csvfile, **options)
Example #3
Source File: udo_inter_substep_update.py From cadCAD with MIT License | 4 votes |
def write(self, ds_uri): pd.to_csv(ds_uri) # Generic update function
Example #4
Source File: udo.py From cadCAD with MIT License | 4 votes |
def write(self, ds_uri): pd.to_csv(ds_uri) # ToDo: Generic update function