### List Datasets Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/HDF5ReaderUtil/listDatasets.html Demonstrates how to use the `listDatasets` static method to get a list of all datasets within an HDF5 file. Ensure the HDF5 file exists at the specified path. ```dart var datasets = await HDF5ReaderUtil.listDatasets('data.h5'); print('Available datasets: $datasets'); ``` -------------------------------- ### Read Bytes From File Example (Desktop) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIO/readBytesFromFile.html Demonstrates how to read the byte content of a file using the readBytesFromFile method. This example assumes a desktop environment where dart:io is available. ```dart var fileIO = FileIO(); var bytes = await fileIO.readBytesFromFile("/path/to/file.xlsx"); ``` -------------------------------- ### Example Usage of writeMultiple Source: https://pub.dev/documentation/dartframe/latest/dartframe/HDF5Writer/writeMultiple.html Demonstrates how to call the writeMultiple method with a map of dataset names to DataFrames. This example shows the intended usage for writing multiple datasets. ```dart await HDF5Writer.writeMultiple('data.h5', { '/temperature': tempDf, '/humidity': humidityDf, '/pressure': pressureDf, }); ``` -------------------------------- ### Example Usage of Series.str.get Source: https://pub.dev/documentation/dartframe/latest/dartframe/StringSeriesAccessor/get.html Demonstrates how to use the `get` method to extract the first element (index 0) from each list in a Series. This is useful when your Series contains lists and you need to access elements by their position. ```dart var s = Series([['a', 'b'], ['c', 'd']], name: 'lists'); var first = s.str.get(0); // Returns ['a', 'c'] ``` -------------------------------- ### Slice DataFrame with Custom Start and Step Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameAdvancedSlicing/sliceRange.html Select rows starting from a specific index with a custom step. This example selects every third row starting from the second row (index 1). ```dart var result = df.sliceRange(start: 1, end: 10, step: 3); // Returns rows 1, 4, 7 ``` -------------------------------- ### Save to File Example (Desktop) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIOBase/saveToFile.html On desktop, provide the full file path as the first argument and the content as the second. Ensure the path is valid and the application has write permissions. ```dart var fileIO = FileIO(); await fileIO.saveToFile("/path/to/file.txt", "This is some content."); ``` -------------------------------- ### Get Top N Largest Values Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameStatistics/nlargest.html Use nlargest to retrieve the rows with the highest values in a specified column. This example shows how to get the top 3 scores. ```dart var df = DataFrame.fromRows([ {'Name': 'Alice', 'Score': 95}, {'Name': 'Bob', 'Score': 87}, {'Name': 'Charlie', 'Score': 92}, {'Name': 'David', 'Score': 88}, ]); var top3 = df.nlargest(3, 'Score'); // Returns rows for Alice (95), Charlie (92), David (88) ``` -------------------------------- ### Select Backend Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/NDArrayConfig/selectBackend.html Instantiate NDArrayConfig.selectBackend with a shape and optional initial data to automatically determine the best storage backend. ```dart var backend = NDArrayConfig.selectBackend( Shape([1000, 1000]), initialData: data, ); ``` -------------------------------- ### Save to File Example (Desktop) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIO/saveToFile.html Demonstrates saving content to a specified file path on a desktop platform. ```dart var fileIO = FileIO(); await fileIO.saveToFile("/path/to/file.txt", "This is some content."); ``` -------------------------------- ### Get Reference Type Source: https://pub.dev/documentation/dartframe/latest/dartframe/ReferenceDatatypeWriter/referenceType.html Accesses the current reference type. No setup or imports are required for this getter. ```dart ReferenceType get referenceType => _referenceType; ``` -------------------------------- ### Example Usage of openRandomAccess (Desktop) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIO/openRandomAccess.html Demonstrates how to open a file for random access, set the position, read bytes, and close the file on a desktop environment. ```dart var fileIO = FileIO(); var raf = await fileIO.openRandomAccess("/path/to/file.dat"); await raf.setPosition(100); var bytes = await raf.read(50); await raf.close(); ``` -------------------------------- ### NDArray toFlatList Examples Source: https://pub.dev/documentation/dartframe/latest/dartframe/NDArray/toFlatList.html Demonstrates how to use the toFlatList method to get a flattened list representation of an NDArray. Shows usage with 2D and 3D arrays, and the option to get a reference instead of a copy. ```dart var arr = NDArray([[1, 2, 3], [4, 5, 6]]); print(arr.toFlatList()); // [1, 2, 3, 4, 5, 6] // Get reference (no copy) var ref = arr.toFlatList(copy: false); // 3D array flattened var arr3d = NDArray([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]); print(arr3d.toFlatList()); // [1, 2, 3, 4, 5, 6, 7, 8] ``` -------------------------------- ### Get vlenType Property Source: https://pub.dev/documentation/dartframe/latest/dartframe/VlenDatatypeWriter/vlenType.html Use this getter to retrieve the variable-length type. No specific setup is required beyond having an instance of the class. ```dart VlenType get vlenType => _vlenType; ``` -------------------------------- ### StorageBackend() Source: https://pub.dev/documentation/dartframe/latest/dartframe/StorageBackend/StorageBackend.html Constructs a new instance of StorageBackend. ```APIDOC ## StorageBackend() ### Description Constructs a new instance of the StorageBackend. ### Method constructor ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response (Instance) - **StorageBackend** (object) - A new instance of StorageBackend. #### Response Example ```dart var storage = StorageBackend(); ``` ``` -------------------------------- ### Example of sliceReplace Source: https://pub.dev/documentation/dartframe/latest/dartframe/StringSeriesAccessor/sliceReplace.html Demonstrates how to use sliceReplace to substitute a part of a string with new content. The slice is defined by start and stop indices. ```dart var s = Series(['abcdef'], name: 'text'); var replaced = s.str.sliceReplace(1, 4, 'XYZ'); // Returns ['aXYZef'] ``` -------------------------------- ### Get Parent Path Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIOBase/getParentPath.html Demonstrates how to use getParentPath to find the parent directory of a file. On web, this will return an empty string. ```dart var fileIO = FileIO(); var parentPath = fileIO.getParentPath("/path/to/file.txt"); // Returns: "/path/to" ``` -------------------------------- ### SmartLoader.initialize Source: https://pub.dev/documentation/dartframe/latest/dartframe/SmartLoader-class.html Initializes the SmartLoader with default data sources. ```APIDOC ## initialize() ### Description Initializes the SmartLoader with default data sources. ### Method `static void initialize()` ``` -------------------------------- ### DataFrame abs() Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameOperations/abs.html Demonstrates how to use the abs() method to get the absolute values of numeric columns. Non-numeric columns are unaffected. ```dart var df = DataFrame([ [-1, -10], [2, -20], [-3, 30], ], columns: ['A', 'B']); var result = df.abs(); // A: [1, 2, 3] // B: [10, 20, 30] ``` -------------------------------- ### connect Method Source: https://pub.dev/documentation/dartframe/latest/dartframe/PostgreSQLConnection-class.html Establishes a connection to the PostgreSQL database. ```APIDOC ## connect() ### Description Establishes a connection to the PostgreSQL database. ### Returns Future ``` -------------------------------- ### HeapManager Example Usage Source: https://pub.dev/documentation/dartframe/latest/dartframe/HeapManager-class.html Demonstrates how to create a HeapManager and allocate data in local and global heaps. Ensure necessary imports like 'dart:convert' for utf8.encode. ```dart final heapManager = HeapManager(formatVersion: 0); // Allocate in local heap for object names final nameOffset = heapManager.allocate( HeapType.local, utf8.encode('dataset_name'), ); // Allocate in global heap for large strings final heapId = heapManager.allocate( HeapType.global, utf8.encode('large string data...'), ); ``` -------------------------------- ### Create DTypeRegistry Instance Source: https://pub.dev/documentation/dartframe/latest/dartframe/DTypeRegistry/DTypeRegistry.html Use the factory constructor `DTypeRegistry()` to get the singleton instance. No setup or imports are required beyond the class definition. ```dart factory DTypeRegistry() => _instance; ``` -------------------------------- ### Registering and Using Data Sources Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataSourceRegistry-class.html Demonstrates how to register a custom data source and find a handler for a given URI. ```APIDOC ## Example ```dart // Register a custom source DataSourceRegistry.register(S3DataSource()); // Find handler for a URI final source = DataSourceRegistry.findByUri(Uri.parse('s3://bucket/data.csv')); if (source != null) { final df = await source.read(uri, {}); } ``` ``` -------------------------------- ### Get Scheme Property - Dart Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataSource/scheme.html Implement this getter to return the URI scheme your data source handles. Examples include 'http', 's3', or 'postgresql'. ```dart String get scheme; ``` -------------------------------- ### Get Column Data Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataCube/getColumn.html Demonstrates how to use the getColumn method to retrieve a column and print its shape. Ensure the DataCube is initialized before calling this method. ```dart var cube = DataCube.generate(3, 4, 5, (d, r, c) => d * 10 + r); var col0 = cube.getColumn('col_0'); print(col0.shape); // [3, 4] ``` -------------------------------- ### DataFrame Constructor Examples Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrame/DataFrame.html Demonstrates creating DataFrames with specified columns and index, with default columns and index, and creating empty DataFrames. ```dart final df1 = DataFrame( [ [1, 'Alice', 100.0], [2, 'Bob', 200.0], ], columns: ['ID', 'Name', 'Score'], index: ['rowA', 'rowB'], ); print(df1); ``` ```dart final df2 = DataFrame([ [10, 20], [30, 40], ]); print(df2); ``` ```dart final df3 = DataFrame(null, columns: ['X', 'Y']); // or DataFrame([], columns: ['X', 'Y']) print(df3.columns); // Output: [X, Y] print(df3.rowCount); // Output: 0 ``` -------------------------------- ### Example Usage of toNDArray Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataCube/toNDArray.html Demonstrates how to create a DataCube and then convert it back to an NDArray to inspect its shape. No special setup is required beyond creating the DataCube. ```dart var cube = DataCube.generate(2, 3, 4, (d, r, c) => d * 10 + r); var array = cube.toNDArray(); print(array.shape); // [2, 3, 4] ``` -------------------------------- ### Example Usage of Series unique() Source: https://pub.dev/documentation/dartframe/latest/dartframe/SeriesFunctions/unique.html Demonstrates how to use the unique() method to get unique values from a Series. The order of elements is preserved, keeping the first occurrence. ```dart var s = Series([1, 2, 3, 1, 2], name: 'numbers'); var unique = s.unique(); print(unique); // Output: numbers (Unique): [1, 2, 3] ``` -------------------------------- ### connect Method Source: https://pub.dev/documentation/dartframe/latest/dartframe/SQLiteConnection-class.html Establishes the connection to the SQLite database. ```APIDOC ## connect() ### Description Connects to the SQLite database using the provided connection string. ### Returns Future - A future that completes when the connection is established. ``` -------------------------------- ### Resolve Path Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIOBase/resolvePath.html Demonstrates how to use resolvePath to combine a base path with a relative path. Note the behavior difference between desktop and web environments. ```dart var fileIO = FileIO(); var resolved = fileIO.resolvePath("/base/path", "../other/file.txt"); // Returns: "/base/other/file.txt" ``` -------------------------------- ### Get Access Pattern Implementation Source: https://pub.dev/documentation/dartframe/latest/dartframe/ChunkedBackend/accessPattern.html This getter retrieves the current access pattern by calling the _detectAccessPattern method. No specific setup is required beyond the class definition. ```dart AccessPattern get accessPattern => _detectAccessPattern(); ``` -------------------------------- ### Example Usage of String Series Slice Source: https://pub.dev/documentation/dartframe/latest/dartframe/StringSeriesAccessor/slice.html Demonstrates how to use the slice method to extract substrings from a Series of strings. The start index is inclusive, and the stop index is exclusive. ```dart var s = Series(['abcdef', '123456'], name: 'text'); var sliced = s.str.slice(1, 4); // Returns ['bcd', '234'] ``` -------------------------------- ### Initialize HDF5FileBuilder Source: https://pub.dev/documentation/dartframe/latest/dartframe/HDF5FileBuilder/HDF5FileBuilder.html Use the constructor to create an instance of HDF5FileBuilder. It accepts an optional formatVersion parameter. ```dart HDF5FileBuilder({ int formatVersion = 0, }) ``` ```dart HDF5FileBuilder({int formatVersion = 0}) : _writer = ByteWriter(), _addresses = {}, _symbolTableWriter = SymbolTableWriter(), _dataLayoutWriter = DataLayoutMessageWriter(), _dataWriter = DataWriter(), _heapManager = HeapManager(formatVersion: formatVersion), _groupWriter = GroupWriter(formatVersion: formatVersion), _groups = {}, _datasets = {}; ``` -------------------------------- ### Start, Stop, and Get Profiler Report Source: https://pub.dev/documentation/dartframe/latest/dartframe/Profiler-class.html Use Profiler.start() to begin timing an operation, Profiler.stop() to end it and record statistics, and Profiler.getReport() to retrieve a summary of all profiled operations. ```dart Profiler.start('myOperation'); // ... perform operation ... Profiler.stop('myOperation'); final report = Profiler.getReport(); print(report); ``` -------------------------------- ### initialize Source: https://pub.dev/documentation/dartframe/latest/dartframe/CompressionRegistry-class.html Initializes the registry with a set of built-in compression codecs. This should typically be called once at the application's startup. ```APIDOC ## initialize() ### Description Initialize registry with built-in codecs. ### Method Signature `initialize() → void` ``` -------------------------------- ### DataFrame sliceByLabelWithStep Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameAdvancedSlicing/sliceByLabelWithStep.html Demonstrates how to slice a DataFrame from a starting row label to an ending row label with a step of 2. Ensure the DataFrame is initialized with appropriate data and index. ```dart var df = DataFrame.fromMap({ 'A': [1, 2, 3, 4, 5], 'B': [10, 20, 30, 40, 50], 'C': [100, 200, 300, 400, 500] }, index: ['a', 'b', 'c', 'd', 'e'] ); // Slice from 'a' to 'd', every other row var result = df.sliceByLabelWithStep( rowStart: 'a', rowEnd: 'd', rowStep: 2 ); ``` -------------------------------- ### Initialize and use InMemoryBackend Source: https://pub.dev/documentation/dartframe/latest/dartframe/InMemoryBackend-class.html Demonstrates creating an InMemoryBackend with initial data and shape, then accessing and modifying a value. ```dart var backend = InMemoryBackend([1, 2, 3, 4, 5, 6], Shape([2, 3])); print(backend.getValue([0, 1])); // 2 backend.setValue([1, 2], 99); ``` -------------------------------- ### initialize static method Source: https://pub.dev/documentation/dartframe/latest/dartframe/SmartLoader/initialize.html Initializes the SmartLoader with default data sources. This is called automatically on first use, but can be called manually to ensure initialization happens at a specific time. ```APIDOC ## initialize() ### Description Initializes the SmartLoader with default data sources. This is called automatically on first use, but can be called manually to ensure initialization happens at a specific time. ### Method Signature `static void initialize()` ### Implementation Details Registers built-in data sources: FileDataSource, HttpDataSource, ScientificDataSource, and DatabaseDataSource. Sets an internal flag to prevent re-initialization. ``` -------------------------------- ### Example Usage of readSlice Source: https://pub.dev/documentation/dartframe/latest/dartframe/Dataset/readSlice.html Demonstrates how to read a slice of a 2D dataset, specifying start and end indices for rows and columns. Null for an end index indicates reading until the end of that dimension. ```dart // Read rows 10-20 from a 2D dataset final slice = await dataset.readSlice( reader, start: [10, 0], end: [20, null], // null means to the end ); ``` -------------------------------- ### initialize static method Source: https://pub.dev/documentation/dartframe/latest/dartframe/CompressionRegistry/initialize.html Initializes the registry with built-in codecs. This method can only be called once. ```APIDOC ## initialize() ### Description Initializes the registry with built-in codecs. This method registers `NoneCodec`, `GzipCodec`, and `ZlibCodec`, and sets `GzipCodec` as the default. ### Method static void ### Parameters None ### Implementation Details - The method checks if the registry has already been initialized (`_codecs.isNotEmpty`). If so, it returns early. - It then calls `register()` for each of the built-in codecs. - Finally, it sets `_defaultCodec` to an instance of `GzipCodec`. ``` -------------------------------- ### Example Usage of zfill Source: https://pub.dev/documentation/dartframe/latest/dartframe/StringSeriesAccessor/zfill.html Demonstrates how to use the zfill method to pad string Series with leading zeros. Ensure the Series contains strings that can be padded. ```dart var s = Series(['1', '22', '333'], name: 'numbers'); var padded = s.str.zfill(5); // Returns ['00001', '00022', '00333'] ``` -------------------------------- ### Get Every Nth Row with Offset Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameAdvancedSlicing/everyNthRow.html Use the everyNthRow method to select rows at a regular interval. Specify the step size 'n' and an optional 'offset' to determine the starting row. ```dart var df = DataFrame.fromMap({ 'A': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }); // Every 3rd row var result = df.everyNthRow(3); // Returns rows 0, 3, 6, 9 // Every 3rd row starting from index 1 var result = df.everyNthRow(3, offset: 1); // Returns rows 1, 4, 7 ``` -------------------------------- ### Example Usage of MATReader.readAll Source: https://pub.dev/documentation/dartframe/latest/dartframe/MATReader/readAll.html Demonstrates how to call the `readAll` method and access the loaded variables. Ensure the MAT file exists at the specified path. ```dart final allData = await MATReader.readAll('experiment.mat'); print('Variables: ${allData.keys}'); print('Matrix A: ${allData['A']}'); ``` -------------------------------- ### Get String Datatype Class in Dart HDF5 Source: https://pub.dev/documentation/dartframe/latest/dartframe/StringDatatypeWriter/datatypeClass.html Override the `datatypeClass` getter to return the HDF5 datatype class enum value. This example specifically shows how to return the string datatype class. ```dart @override Hdf5DatatypeClass get datatypeClass => Hdf5DatatypeClass.string; ``` -------------------------------- ### Example Usage of DataCube tile Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataCubeTransformations/tile.html Demonstrates how to tile a DataCube by repeating it along each axis. Ensure the input DataCube is initialized before tiling. ```dart var cube = DataCube.zeros(2, 3, 4); var tiled = cube.tile(depthReps: 2, rowReps: 1, colReps: 3); // Shape becomes [4, 3, 12] ``` -------------------------------- ### Save to File Example (Web) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIOBase/saveToFile.html On the web, provide the content as the first argument and the desired filename as the second. The browser will typically prompt the user to download the file. ```dart var fileIO = FileIO(); await fileIO.saveToFile("This is some content.", "file.txt"); ``` -------------------------------- ### Example Usage of resolveRegionReference Source: https://pub.dev/documentation/dartframe/latest/dartframe/Hdf5File/resolveRegionReference.html Demonstrates how to open an HDF5 file, obtain region reference data from a dataset, and then use `resolveRegionReference` to get information about the referenced region. Prints the address of the referenced dataset. ```dart final file = await Hdf5File.open('data.h5'); final refData = ...; // Region reference data from a dataset final refInfo = await file.resolveRegionReference(refData); print('Referenced dataset at address: 0x${refInfo['address'].toRadixString(16)}'); ``` -------------------------------- ### connect method Source: https://pub.dev/documentation/dartframe/latest/dartframe/MySQLConnection/connect.html Establishes a connection to the MySQL database using a provided connection string. It parses the connection details, validates the scheme, and initiates the connection. ```APIDOC ## connect() ### Description Establishes a connection to the MySQL database. ### Method Signature Future connect() ### Implementation Details - Parses the connection string to extract host, port, username, password, and database name. - Validates that the connection string scheme is 'mysql'. - Throws a `DatabaseConnectionError` if the connection string is empty, invalid, or if the connection fails. ### Example Usage ```dart final connection = MySQLConnection('mysql://user:password@host:port/database'); await connection.connect(); ``` ``` -------------------------------- ### Apply Function to DataFrame Groups Source: https://pub.dev/documentation/dartframe/latest/dartframe/GroupBy/apply.html Use this method to apply a function to each group. The function should accept a DataFrame (representing a group) and return a DataFrame. This example demonstrates getting the first two rows of each group. ```dart var result = df.groupBy2(['category']).apply((group) => group.head(2) // Get first 2 rows of each group ); ``` -------------------------------- ### Slice.from(int start) Source: https://pub.dev/documentation/dartframe/latest/dartframe/Slice-class.html Creates a slice specification to select elements from a start index to the end. Equivalent to `[start:]`. ```APIDOC ## Slice.from(int start) ### Description Selects elements from a specified start index to the end of the collection. ### Method static SliceSpec from(int start) ### Parameters #### Path Parameters - **start** (int) - Required - The starting index (inclusive) for the slice. ``` -------------------------------- ### Load and Write DataFrame Examples Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameSmartLoader.html Demonstrates loading DataFrames from different sources like CSV, JSON URLs, and custom datasets. Also shows writing DataFrames to CSV and JSON formats, with options for JSON orientation. ```dart final df1 = await DataFrame.read('data.csv'); final df2 = await DataFrame.read('https://example.com/data.json'); final df3 = await DataFrame.read('dataset://iris'); ``` ```dart await df.write('output.csv'); await df.write('output.json', options: {'orient': 'records'}); ``` -------------------------------- ### DataFrame Lead Method Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameTimeSeries/lead.html Demonstrates how to use the lead method to shift data forward by one or two periods. Newly introduced missing values are represented as null. ```dart var df = DataFrame.fromMap({'A': [1, 2, 3, 4, 5]}); var led = df.lead(1); // [2, 3, 4, 5, null] var led2 = df.lead(2); // [3, 4, 5, null, null] ``` -------------------------------- ### sampleWeighted Method Examples Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameSamplingEnhanced/sampleWeighted.html Examples demonstrating how to use the sampleWeighted method. ```APIDOC ## Example Usage ```dart var df = DataFrame.fromMap({ 'item': ['A', 'B', 'C', 'D'], 'weight': [0.1, 0.2, 0.3, 0.4] }); // Sample 2 items with weights var sampled = df.sampleWeighted(n: 2, weights: 'weight'); // Sample 50% with custom weights var sampled2 = df.sampleWeighted( frac: 0.5, weights: [1, 2, 3, 4], randomState: 42 ); ``` ``` -------------------------------- ### JsonReadError Usage Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/JsonReadError-class.html Example demonstrating how to catch a JsonReadError when reading JSON data. ```APIDOC ## Example: ```dart try { final df = await JsonReader().read('data.json'); } on JsonReadError catch (e) { print('Failed to read JSON: $e'); } ``` ``` -------------------------------- ### DataFrame Info Method Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameInspection/info.html Demonstrates how to use the info() method to display a summary of a DataFrame. This includes column names, data types, non-null counts, and memory usage. ```dart var df = DataFrame.fromMap({ 'A': [1, 2, null, 4], 'B': ['a', 'b', 'c', 'd'], 'C': [1.1, 2.2, 3.3, 4.4], }); df.info(); ``` -------------------------------- ### Example Usage of writeBytesToFile (Desktop) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIO/writeBytesToFile.html Demonstrates how to use the writeBytesToFile method to save binary data to a file on a desktop environment. Ensure the 'bytes' variable is populated with the data to be written. ```dart var fileIO = FileIO(); await fileIO.writeBytesToFile("/path/to/file.xlsx", bytes); ``` -------------------------------- ### Custom Comparators Example Source: https://pub.dev/documentation/dartframe/latest/dartframe/listEqual.html Provides an example of how to define custom comparison functions for specific data types. ```APIDOC ### Custom comparators: ```dart final customConfig = ListEqualConfig( customComparators: { DateTime: (a, b) => (a as DateTime).millisecondsSinceEpoch == (b as DateTime).millisecondsSinceEpoch, } ); ``` ``` -------------------------------- ### Get Unique Categories Source: https://pub.dev/documentation/dartframe/latest/dartframe/CategoricalAccessor/unique.html Returns unique categories from the data. Set `sort` to true to get sorted results. ```dart List unique({bool sort = false}) { return _series._categorical!.unique(sort: sort); } ``` -------------------------------- ### Inspect Available Datasets Source: https://pub.dev/documentation/dartframe/latest/dartframe/SmartLoader/inspect.html This example shows how to inspect a 'dataset://' URI to retrieve a list of available datasets. It prints the 'available_datasets' property from the inspection result. ```dart final datasets = await SmartLoader.inspect('dataset://'); print('Available datasets: ${datasets['available_datasets']}'); ``` -------------------------------- ### Implementing a Custom Data Source Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataSource-class.html Demonstrates how to create a custom data source by extending the DataSource abstract class and implementing its core methods: `scheme`, `canHandle`, `read`, and `write`. It also shows how to register the custom data source with the `DataSourceRegistry`. ```APIDOC ## Implementing a Custom Data Source To create a custom data source, extend the `DataSource` abstract class and implement the following: - **`scheme`**: A getter that returns the URI scheme this data source handles (e.g., 'custom'). - **`canHandle(Uri uri)`**: A method that returns `true` if this data source can handle the given URI, `false` otherwise. - **`read(Uri uri, Map options)`**: An asynchronous method that reads data from the source and returns a `DataFrame`. - **`write(DataFrame df, Uri uri, Map options)`**: An asynchronous method that writes a `DataFrame` to the source. After implementation, register your custom data source using `DataSourceRegistry.register()`. ```dart class MyCustomSource extends DataSource { @override String get scheme => 'custom'; @override bool canHandle(Uri uri) => uri.scheme == 'custom'; @override Future read(Uri uri, Map options) async { // Your implementation to read data throw UnimplementedError(); // Placeholder } @override Future write(DataFrame df, Uri uri, Map options) async { // Your implementation to write data throw UnimplementedError(); // Placeholder } } // Register the custom data source DataSourceRegistry.register(MyCustomSource()); ``` ``` -------------------------------- ### Example Usage of toLatex Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameExportFormats/toLatex.html This example demonstrates how to use the toLatex method to export a DataFrame to a LaTeX table with a caption and label. ```APIDOC ### Example ```dart var df = DataFrame([ ['Alice', 25, 50000], ['Bob', 30, 60000], ], columns: ['Name', 'Age', 'Salary']); var latex = df.toLatex( caption: 'Employee Data', label: 'tab:employees', ); print(latex); ``` ``` -------------------------------- ### Example Usage of createReference Source: https://pub.dev/documentation/dartframe/latest/dartframe/GlobalHeapWriter/createReference.html Demonstrates how to allocate an object, write a collection, and then create a reference to that object using its ID and heap address. ```dart final heapWriter = GlobalHeapWriter(); final objectId = heapWriter.allocate(utf8.encode('Data')); final heapAddress = 2048; // Write heap collection at address 2048 final collectionBytes = heapWriter.writeCollection(heapAddress); // Create reference to the object final reference = heapWriter.createReference(objectId, heapAddress); // Use reference in dataset or attribute ``` -------------------------------- ### Get Memory Usage Source: https://pub.dev/documentation/dartframe/latest/dartframe/BackendStatsMixin/memoryUsage.html Access the memoryUsage property to get an estimate of the memory used by the backend in bytes. This is an integer value. ```dart int get memoryUsage; ``` -------------------------------- ### Create HDF5 file for testing Source: https://pub.dev/documentation/dartframe/latest/dartframe/NDArrayHDF5Reader/fromHDF5.html This Python example demonstrates how to create an HDF5 file with a dataset named '/measurements' using the h5py library, which can then be read by the Dart `fromHDF5` method. ```python import h5py import numpy as np data = np.random.rand(100, 200) with h5py.File('data.h5', 'w') as f: f.create_dataset('/measurements', data=data) ``` -------------------------------- ### SliceSpec Start Property Declaration Source: https://pub.dev/documentation/dartframe/latest/dartframe/SliceSpec/start.html Declares the nullable integer 'start' property for SliceSpec. Use this to specify the inclusive beginning index of a slice. ```dart final int? start; ``` -------------------------------- ### Convert PeriodIndex to DatetimeIndex Source: https://pub.dev/documentation/dartframe/latest/dartframe/PeriodIndex/toTimestamp.html Converts the `PeriodIndex` to a `DatetimeIndex` using either the start or end time of each period. Defaults to using the start time. ```dart DatetimeIndex toTimestamp({String how = 'start'}) { final timestamps = _periods.map((p) { return how == 'start' ? p.startTime : p.endTime; }).toList(); return DatetimeIndex(timestamps, name: _name, frequency: _frequency); } ``` -------------------------------- ### DataFrame.take() Examples Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameSamplingEnhanced/take.html Demonstrates selecting rows and columns using the `take` method. Supports positive and negative indices for rows and columns. ```dart var df = DataFrame.fromMap({ 'A': [1, 2, 3, 4, 5], 'B': [10, 20, 30, 40, 50] }); // Take rows at positions 0, 2, 4 var result = df.take([0, 2, 4]); // Returns rows 0, 2, 4 // Take columns at positions 0 var result2 = df.take([0], axis: 1); // Returns only column A // Take with negative indices (from end) var result3 = df.take([-1, -2]); // Returns last two rows ``` -------------------------------- ### Example Usage of writeMultipleBlocks Source: https://pub.dev/documentation/dartframe/latest/dartframe/LocalHeapWriter/writeMultipleBlocks.html Demonstrates how to use writeMultipleBlocks when the heap data requires splitting into multiple blocks. This snippet shows the conditional check and subsequent sequential writing of blocks. ```dart final heapWriter = LocalHeapWriter(); // ... allocate lots of data ... if (heapWriter.needsMultipleBlocks) { final blocks = heapWriter.writeMultipleBlocks(2048); // Write each block to file sequentially } ``` -------------------------------- ### startTime property Source: https://pub.dev/documentation/dartframe/latest/dartframe/Period/startTime.html Retrieves the start time of the period. The exact start time is determined by the period's frequency (D for daily, M for monthly, Y for yearly). ```APIDOC ## startTime property ### Description DateTime get startTime Start time of the period. ### Implementation ```dart DateTime get startTime { switch (_frequency.toUpperCase()) { case 'D': return DateTime(_date.year, _date.month, _date.day); case 'M': return DateTime(_date.year, _date.month, 1); case 'Y': return DateTime(_date.year, 1, 1); default: return _date; } } ``` ``` -------------------------------- ### Get All Codec Names - Dart Source: https://pub.dev/documentation/dartframe/latest/dartframe/CompressionRegistry/getNames.html Call this static method to get a list of all registered codec names. Ensure the registry is initialized before calling. ```dart static List getNames() { initialize(); return _codecs.keys.toList(); } ``` -------------------------------- ### fromBinary static method Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataCubeImport/fromBinary.html Imports a DataCube from a binary file. Note: This method is currently unimplemented and requires shape information. ```APIDOC ## fromBinary static method Future fromBinary( 1. String path ) Import from binary file ### Description Imports a DataCube from a binary file specified by the given path. ### Method Signature `static Future fromBinary(String path)` ### Parameters #### Path Parameters - **path** (String) - Required - The path to the binary file to import. ``` -------------------------------- ### Save to File Example (Web) Source: https://pub.dev/documentation/dartframe/latest/dartframe/FileIO/saveToFile.html Demonstrates saving content to a file with a specified filename on a web platform. ```dart var fileIO = FileIO(); await fileIO.saveToFile("This is some content.", "file.txt"); ``` -------------------------------- ### Get Memory Recommendations Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameMemoryOptimization/memoryRecommendations.html Access the `memoryRecommendations` property to get a map of string keys to string values, where each entry represents a memory optimization suggestion. ```APIDOC ## memoryRecommendations property ### Description Gets memory optimization recommendations for this DataFrame. ### Method Signature `Map get memoryRecommendations` ### Returns A `Map` containing memory optimization recommendations. ``` -------------------------------- ### Create an Integer Range Index with AxisIndex.range Source: https://pub.dev/documentation/dartframe/latest/dartframe/AxisIndex/AxisIndex.range.html Use this factory constructor to create an AxisIndex with a specified length, starting from a given integer. The default start is 0. ```dart var index = AxisIndex.range(10); // [0, 1, 2, ..., 9] ``` -------------------------------- ### GzipFilter Usage for Writing and Reading Source: https://pub.dev/documentation/dartframe/latest/dartframe/GzipFilter-class.html Demonstrates how to create a GzipFilter for writing with a specified compression level and how to create one for reading. The compression level is only relevant when encoding data. ```dart // For writing with compression level 6 final filter = GzipFilter(compressionLevel: 6); final compressed = filter.encode(rawData); // For reading (compression level not needed) final filter = GzipFilter.forReading(flags: 0, clientData: []); final decompressed = await filter.decode(compressedData); ``` -------------------------------- ### Example Usage of Hdf5File.close() Source: https://pub.dev/documentation/dartframe/latest/dartframe/Hdf5File/close.html Demonstrates the recommended pattern for closing an HDF5 file using a try-finally block to ensure cleanup. ```dart final file = await Hdf5File.open('data.h5'); try { // ... use the file } finally { await file.close(); } ``` -------------------------------- ### toAtom Method Example Usage Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameWebAPI/toAtom.html An example demonstrating how to use the toAtom method to create an Atom feed from a DataFrame, specifying the necessary columns for titles and content. ```APIDOC ### Example ```dart var atom = df.toAtom( title: 'Blog Posts', id: 'https://example.com/feed', titleCol: 'title', contentCol: 'body', ); ``` ``` -------------------------------- ### Get the last 5 rows of a Series Source: https://pub.dev/documentation/dartframe/latest/dartframe/SeriesFunctions/tail.html Use the tail() method without arguments to get the last 5 rows. The default value for n is 5. ```dart var s = Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name: 'numbers'); var last5 = s.tail(); print(last5); // Output: numbers: [6, 7, 8, 9, 10] ``` -------------------------------- ### connect Source: https://pub.dev/documentation/dartframe/latest/dartframe/MySQLConnection-class.html Establishes a connection to the database. ```APIDOC ## connect() ### Description Establishes a connection to the database. ### Returns - Future - A future that completes when the connection is established. ``` -------------------------------- ### fromFile static method Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataCubeImportExtension/fromFile.html Creates a DataCube from a file, automatically detecting the file format. ```APIDOC ## fromFile static method ### Description Create DataCube from file (auto-detect format) ### Signature ```dart static Future fromFile(String path) ``` ### Parameters #### Path Parameters - **path** (String) - Required - The path to the file to import. ``` -------------------------------- ### Get First 5 Rows of a Series Source: https://pub.dev/documentation/dartframe/latest/dartframe/SeriesFunctions/head.html Use the head() method without arguments to get the first 5 rows. The default value for n is 5. ```dart var s = Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], name: 'numbers'); var first5 = s.head(); print(first5); // Output: numbers: [1, 2, 3, 4, 5] ``` -------------------------------- ### Get Codes Property Implementation Source: https://pub.dev/documentation/dartframe/latest/dartframe/MultiIndex/codes.html Retrieves a deep copy of the internal codes. Use this to get the list of codes without modifying the original internal list. ```dart List> get codes => _codes.map((c) => List.from(c)).toList(); ``` -------------------------------- ### Initialize DCFReader Source: https://pub.dev/documentation/dartframe/latest/dartframe/DCFReader/DCFReader.html Use this constructor to create a new DCFReader instance, providing the path to the DCF file. ```dart DCFReader(this._path); ``` -------------------------------- ### List Datasets Implementation Source: https://pub.dev/documentation/dartframe/latest/dartframe/DCFUtil/listDatasets.html This implementation shows how to use DCFReader to open a file, list its datasets, and ensure the reader is closed afterward. It's essential to handle potential exceptions during file operations. ```dart static Future> listDatasets(String path) async { final reader = DCFReader(path); await reader.open(); try { return reader.listDatasets(); } finally { await reader.close(); } } ``` -------------------------------- ### SliceSpec Constructor Source: https://pub.dev/documentation/dartframe/latest/dartframe/SliceSpec/SliceSpec.html Constructs a SliceSpec object to define slicing parameters. Allows specifying start, stop, and step indices for inclusive start and exclusive stop slicing. ```APIDOC ## SliceSpec Constructor ### Description Creates a slice specification with optional start, stop, and step parameters. ### Parameters #### Positional Parameters - **start** (int?) - The starting index (inclusive). If null, it represents the beginning. - **stop** (int?) - The stopping index (exclusive). If null, it represents the end. #### Named Parameters - **step** (int) - The step size. Must be non-zero. Defaults to 1. ### Example ```dart var slice = SliceSpec(0, 10, step: 2); // Represents a slice from index 0 up to (but not including) index 10, with a step of 2. ``` ### Implementation Notes Throws an `ArgumentError` if the provided `step` is zero. ``` -------------------------------- ### MySQLConnection Constructor Source: https://pub.dev/documentation/dartframe/latest/dartframe/MySQLConnection/MySQLConnection.html Initializes a new MySQLConnection with a given connection string. ```APIDOC ## MySQLConnection(String _connectionString) ### Description Constructs a new MySQLConnection instance. ### Parameters #### Path Parameters - **_connectionString** (String) - Required - The connection string to use for establishing the MySQL connection. ``` -------------------------------- ### Slice.range(int start, int stop, {int step = 1}) Source: https://pub.dev/documentation/dartframe/latest/dartframe/Slice-class.html Creates a slice specification to select a range of elements with an optional step. Equivalent to `[start:stop:step]`. ```APIDOC ## Slice.range(int start, int stop, {int step = 1}) ### Description Selects a range of elements from a collection, with an optional step. ### Method static SliceSpec range(int start, int stop, {int step = 1}) ### Parameters #### Path Parameters - **start** (int) - Required - The starting index (inclusive) for the slice. - **stop** (int) - Required - The ending index (exclusive) for the slice. - **step** (int) - Optional - The interval between selected elements. Defaults to 1. ``` -------------------------------- ### Reading a Dataset in Chunks Source: https://pub.dev/documentation/dartframe/latest/dartframe/Hdf5File/readDatasetChunked.html Demonstrates how to open an HDF5 file and read its dataset in manageable chunks using a for-await-in loop. Useful for large datasets. ```dart final file = await Hdf5File.open('large_data.h5'); await for (final chunk in file.readDatasetChunked('/data', chunkSize: 10000)) { // Process each chunk print('Processing ${chunk.length} elements'); // ... do something with chunk } ``` -------------------------------- ### CompactLayout Constructor Source: https://pub.dev/documentation/dartframe/latest/dartframe/CompactLayout-class.html Initializes a new CompactLayout instance with the provided data. ```APIDOC ## CompactLayout ### Description Initializes a new CompactLayout instance with the provided data. ### Parameters #### Path Parameters - **data** (List) - Required - The list of integers representing the compact data. ``` -------------------------------- ### Get Root Group Source: https://pub.dev/documentation/dartframe/latest/dartframe/Hdf5File/root.html Gets the root group of the HDF5 file. The root group contains all top-level datasets and groups in the file. You can access its children using the Group.children property. ```APIDOC ## Get Root Group ### Description Gets the root group of the HDF5 file. The root group contains all top-level datasets and groups in the file. You can access its children using the Group.children property. ### Example ```dart final file = await Hdf5File.open('data.h5'); print('Root children: ${file.root.children}'); ``` ### Implementation ```dart Group get root => _rootGroup; ``` ``` -------------------------------- ### Implement DataFrame limit method Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameFunctions/limit.html This method returns a new DataFrame containing a specified number of rows, starting from a given index. It includes error handling for invalid start indices. ```dart DataFrame limit(int limit, {int startIndex = 0}) { if (startIndex < 0 || startIndex >= _data.length) { throw ArgumentError('Invalid start index.'); } final endIndex = startIndex + limit; final limitedData = _data.sublist( startIndex, endIndex < _data.length ? endIndex : _data.length); return DataFrame._(_columns, limitedData); } ``` -------------------------------- ### Example Usage of tryStack Source: https://pub.dev/documentation/dartframe/latest/dartframe/DataFrameStacker/tryStack.html Demonstrates how to use the tryStack method and check for compatibility. Use this when you need to stack DataFrames without risking an exception. ```dart var frames = [df1, df2, df3]; var cube = DataFrameStacker.tryStack(frames); if (cube != null) { print('Successfully created DataCube'); } else { print('DataFrames are incompatible'); } ``` -------------------------------- ### connect method Source: https://pub.dev/documentation/dartframe/latest/dartframe/PostgreSQLConnection/connect.html Establishes a connection to a PostgreSQL database using a connection string. It parses the connection details, validates the scheme, and opens a connection using the provided endpoint and settings. Throws a DatabaseConnectionError if the connection string is empty, invalid, or if the connection fails. ```APIDOC ## connect() ### Description Establishes a connection to a PostgreSQL database. ### Method Signature Future connect() ### Implementation Details - Parses the connection string to extract host, port, username, password, and database. - Validates that the connection string scheme is 'postgresql' or 'postgres'. - Uses `pg.Connection.open` to establish the connection. - Sets `pg.SslMode` to `disable`. - Throws `DatabaseConnectionError` on failure. ``` -------------------------------- ### Create SliceSpec Instance Source: https://pub.dev/documentation/dartframe/latest/dartframe/SliceSpec/SliceSpec.html Instantiate SliceSpec with start, stop, and an optional step. The step defaults to 1 if not provided. Use null for start or stop to indicate the beginning or end of the sequence, respectively. ```dart var slice = SliceSpec(0, 10, step: 2); // [0:10:2] ``` -------------------------------- ### DCFReader Constructor Source: https://pub.dev/documentation/dartframe/latest/dartframe/DCFReader/DCFReader.html Initializes a new DCFReader instance with the specified file path. ```APIDOC ## DCFReader Constructor ### Description Initializes a new DCFReader instance. ### Parameters #### Path Parameters - **_path** (String) - Required - The path to the DCF file. ``` -------------------------------- ### Create Slice from Start Index Source: https://pub.dev/documentation/dartframe/latest/dartframe/Slice/from.html Use the `from()` static method to create a slice that begins at the specified start index and extends to the end of the sequence. This is useful for selecting a sub-sequence from a particular point onwards. ```dart var slice = Slice.from(5); // [5:] ``` ```dart static SliceSpec from(int start) => SliceSpec(start, null); ``` -------------------------------- ### dtypeInfo Source: https://pub.dev/documentation/dartframe/latest/dartframe/SeriesDType.html Get the DType of this Series. ```APIDOC ## dtypeInfo ### Description Get the DType of this Series. ### Returns - dtypeInfo (DType) - The data type of the Series. ```