@@ -4597,7 +4597,6 @@ def to_csv(
45974597 path_or_buf : Union [PathLike , BinaryIO ],
45984598 batch_size : Optional [int ] = None ,
45994599 num_proc : Optional [int ] = None ,
4600- index : bool = False ,
46014600 ** to_csv_kwargs ,
46024601 ) -> int :
46034602 """Exports the dataset to csv
@@ -4613,20 +4612,18 @@ def to_csv(
46134612 use multiprocessing. `batch_size` in this case defaults to
46144613 `datasets.config.DEFAULT_MAX_BATCH_SIZE` but feel free to make it 5x or 10x of the default
46154614 value if you have sufficient compute power.
4616- index (`bool`, default `False`): Write row names (index).
4615+ **to_csv_kwargs (additional keyword arguments):
4616+ Parameters to pass to pandas's [`pandas.DataFrame.to_csv`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_json.html).
46174617
46184618 <Changed version="2.10.0">
46194619
4620- Now, `index` defaults to `False`.
4620+ Now, `index` defaults to `False` if not specified .
46214621
4622- If you would like to write the index, set it to ` True` and also set a name for the index column by
4622+ If you would like to write the index, pass `index= True` and also set a name for the index column by
46234623 passing `index_label`.
46244624
46254625 </Changed>
46264626
4627- **to_csv_kwargs (additional keyword arguments):
4628- Parameters to pass to pandas's `pandas.DataFrame.to_csv`.
4629-
46304627 Returns:
46314628 `int`: The number of characters or bytes written.
46324629
@@ -4639,9 +4636,7 @@ def to_csv(
46394636 # Dynamic import to avoid circular dependency
46404637 from .io .csv import CsvDatasetWriter
46414638
4642- return CsvDatasetWriter (
4643- self , path_or_buf , batch_size = batch_size , num_proc = num_proc , index = index , ** to_csv_kwargs
4644- ).write ()
4639+ return CsvDatasetWriter (self , path_or_buf , batch_size = batch_size , num_proc = num_proc , ** to_csv_kwargs ).write ()
46454640
46464641 def to_dict (self , batch_size : Optional [int ] = None , batched : bool = False ) -> Union [dict , Iterator [dict ]]:
46474642 """Returns the dataset as a Python dict. Can also return a generator for large datasets.
@@ -4699,22 +4694,17 @@ def to_json(
46994694 use multiprocessing. `batch_size` in this case defaults to
47004695 `datasets.config.DEFAULT_MAX_BATCH_SIZE` but feel free to make it 5x or 10x of the default
47014696 value if you have sufficient compute power.
4702- lines (`bool`, defaults to `True`):
4703- Whether output JSON lines format.
4704- Only possible if `orient="records"`. It will throw ValueError with `orient` different from
4705- `"records"`, since the others are not list-like.
4706- orient (`str`, defaults to `"records"`):
4707- Format of the JSON:
4708-
4709- - `"records"`: list like `[{column -> value}, … , {column -> value}]`
4710- - `"split"`: dict like `{"index" -> [index], "columns" -> [columns], "data" -> [values]}`
4711- - `"index"`: dict like `{index -> {column -> value}}`
4712- - `"columns"`: dict like `{column -> {index -> value}}`
4713- - `"values"`: just the values array
4714- - `"table"`: dict like `{"schema": {schema}, "data": {data}}`
47154697 **to_json_kwargs (additional keyword arguments):
47164698 Parameters to pass to pandas's [`pandas.DataFrame.to_json`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_json.html).
47174699
4700+ <Changed version="2.11.0">
4701+
4702+ Now, `index` defaults to `False` if `orint` is `"split"` or `"table"` is specified.
4703+
4704+ If you would like to write the index, pass `index=True`.
4705+
4706+ </Changed>
4707+
47184708 Returns:
47194709 `int`: The number of characters or bytes written.
47204710
@@ -4817,7 +4807,16 @@ def to_sql(
48174807 Size of the batch to load in memory and write at once.
48184808 Defaults to `datasets.config.DEFAULT_MAX_BATCH_SIZE`.
48194809 **sql_writer_kwargs (additional keyword arguments):
4820- Parameters to pass to pandas's [`Dataframe.to_sql`].
4810+ Parameters to pass to pandas's [`pandas.DataFrame.to_sql`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_sql.html).
4811+
4812+ <Changed version="2.11.0">
4813+
4814+ Now, `index` defaults to `False` if not specified.
4815+
4816+ If you would like to write the index, pass `index=True` and also set a name for the index column by
4817+ passing `index_label`.
4818+
4819+ </Changed>
48214820
48224821 Returns:
48234822 `int`: The number of records written.
0 commit comments