本文整理匯總了Python中pandas.to_csv方法的典型用法代碼示例。如果您正苦於以下問題:Python pandas.to_csv方法的具體用法?Python pandas.to_csv怎麽用?Python pandas.to_csv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas
的用法示例。
在下文中一共展示了pandas.to_csv方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: execute
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import to_csv [as 別名]
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)
示例2: default_csv_writer
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import to_csv [as 別名]
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)
示例3: write
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import to_csv [as 別名]
def write(self, ds_uri):
pd.to_csv(ds_uri)
# Generic update function
示例4: write
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import to_csv [as 別名]
def write(self, ds_uri):
pd.to_csv(ds_uri)
# ToDo: Generic update function