Write the DataFrame disk in avro format.
File path to which the file should be written, or writable.
Optionaloptions: WriteAvroOptionsOptions for writing Avro files
Optionalcompression?: "uncompressed" | "snappy" | "deflate"Optionaloptions: WriteAvroOptionsWrite DataFrame to comma-separated values file (csv).
If no options are specified, it will return a new string containing the contents
file or stream to write to
Optionaloptions: CsvWriterOptionsOptions for
OptionalbatchSize?: numberOptionaldateFormat?: stringOptionaldatetimeFormat?: stringOptionalfloatPrecision?: numberOptionalincludeBom?: booleanOptionalincludeHeader?: booleanOptionallineTerminator?: stringOptionalmaintainOrder?: booleanOptionalnullValue?: stringOptionalquoteChar?: stringOptionalseparator?: stringOptionaltimeFormat?: string> const df = pl.DataFrame({
... "foo": [1, 2, 3],
... "bar": [6, 7, 8],
... "ham": ['a', 'b', 'c']
... });
> df.writeCSV();
foo,bar,ham
1,6,a
2,7,b
3,8,c
// using a file path
> df.head(1).writeCSV("./foo.csv")
// foo.csv
foo,bar,ham
1,6,a
// using a write stream
> const writeStream = new Stream.Writable({
... write(chunk, encoding, callback) {
... console.log("writeStream: %O', chunk.toString());
... callback(null);
... }
... });
> df.head(1).writeCSV(writeStream, {includeHeader: false});
writeStream: '1,6,a'
Write to Arrow IPC feather file, either to a file path or to a write stream.
File path to which the file should be written, or writable.
Optionaloptions: WriteIPCOptionsOptions for DataFrame.writeIPC
Optionalcompression?: "uncompressed" | "lz4" | "zstd"Optionaloptions: WriteIPCOptionsWrite to Arrow IPC stream file, either to a file path or to a write stream.
File path to which the file should be written, or writable.
Optionaloptions: WriteIPCOptionsOptions for DataFrame.writeIPC
Optionalcompression?: "uncompressed" | "lz4" | "zstd"Optionaloptions: WriteIPCOptionsWrite Dataframe to JSON string, file, or write stream
file or write stream
Optionaloptions: { format: "lines" | "json" }json | lines
> const df = pl.DataFrame({
... foo: [1,2,3],
... bar: ['a','b','c']
... })
> df.writeJSON({format:"json"})
`[ {"foo":1.0,"bar":"a"}, {"foo":2.0,"bar":"b"}, {"foo":3.0,"bar":"c"}]`
> df.writeJSON({format:"lines"})
`{"foo":1.0,"bar":"a"}
{"foo":2.0,"bar":"b"}
{"foo":3.0,"bar":"c"}`
// writing to a file
> df.writeJSON("/path/to/file.json", {format:'lines'})
Optionaloptions: { format: "lines" | "json" }Write the DataFrame disk in parquet format.
File path to which the file should be written, or writable.
Optionaloptions: WriteParquetOptionsOptions for DataFrame.writeParquet
Optionalcompression?: "uncompressed" | "snappy" | "gzip" | "lzo" | "brotli" | "lz4" | "zstd"Optionaloptions: WriteParquetOptions
Write methods for DataFrame