### Install DataFrame using Metacello Source: https://github.com/polymathorg/dataframe/wiki/2.-Installation This script utilizes Metacello, a dependency management tool for Pharo, to load the DataFrame baseline from its GitHub repository. It ensures all necessary dependencies are installed. Tested on Pharo 6.1 and Pharo64-6.1 for Linux, OSX, and Windows. ```Smalltalk Metacello new baseline: 'DataFrame'; repository: 'github://PolyMathOrg/DataFrame'; load. ``` -------------------------------- ### Install Latest DataFrame using Metacello Source: https://github.com/polymathorg/dataframe/blob/master/README.md This script installs the absolute latest version of the DataFrame library from its GitHub repository using Metacello. It also disables Epicea during the installation process. ```Smalltalk EpMonitor disableDuring: [ Metacello new baseline: 'DataFrame'; repository: 'github://PolyMathOrg/DataFrame/src'; load ]. ``` -------------------------------- ### Install DataFrame (pre-v3) using Metacello Source: https://github.com/polymathorg/dataframe/blob/master/README.md This script installs the latest stable version of the DataFrame library (pre-v3) using the Metacello package manager in Pharo. It disables Epicea during installation to prevent interference. ```Smalltalk EpMonitor disableDuring: [ Metacello new baseline: 'DataFrame'; repository: 'github://PolyMathOrg/DataFrame:pre-v3/src'; load ]. ``` -------------------------------- ### Transpose DataFrame Source: https://github.com/polymathorg/dataframe/wiki/9.-Transposed-DataFrame Demonstrates the command or method to transpose a DataFrame. Transposing swaps rows and columns, which is useful for restructuring data. The example shows the input DataFrame structure and the resulting transposed output. ```APIDOC Command/Method: df transposed Description: Swaps the rows and columns of a DataFrame. Usage: Execute `df transposed` to obtain a new DataFrame with rows and columns interchanged. Example Input DataFrame Structure: ``` | A B C ------------+---------------------------- City | Barcelona Dubai London Population | 1.609 2.789 8.788 BeenThere | true true false ``` Example Output Transposed DataFrame Structure: ``` | City Population BeenThere ------------+--------------------------------- A | Barcelona 1.609 true B | Dubai 2.789 true C | London 8.788 false ``` Note: This operation creates a new DataFrame; the original DataFrame remains unchanged. ``` -------------------------------- ### Set DataSeries Name and Keys Source: https://github.com/polymathorg/dataframe/wiki/3.-Creating-DataSeries Illustrates how to customize a DataSeries by setting its name and keys. By default, keys are initialized as an interval, and the name is nil. These messages allow for explicit configuration. ```smalltalk series name: 'letters'. series keys: #(k1 k2 k3). ``` -------------------------------- ### Load Built-in Datasets Source: https://github.com/polymathorg/dataframe/wiki/6.-Creating-DataFrame Provides convenient methods to load several well-known datasets directly into a DataFrame. Currently supported datasets include Iris, a simplified Boston Housing, and the Restaurant tipping dataset. ```smalltalk DataFrame loadIris. DataFrame loadHousing. DataFrame loadTips. ``` -------------------------------- ### Create DataSeries from Array (fromArray:) Source: https://github.com/polymathorg/dataframe/wiki/3.-Creating-DataSeries Demonstrates creating a DataSeries from a Smalltalk array using the `fromArray:` class method. This is a fundamental way to initialize a DataSeries with data. ```smalltalk series := DataSeries fromArray: #(a b c). ``` -------------------------------- ### Create a DataFrame Source: https://github.com/polymathorg/dataframe/blob/master/README.md Demonstrates the creation of a DataFrame object in Pharo. It initializes a DataFrame with specific rows containing mixed data types. ```Smalltalk weather := DataFrame withRows: #( (2.4 true rain) (0.5 true rain) (-1.2 true snow) (-2.3 false -) (3.2 true rain)). ``` -------------------------------- ### Create DataSeries from Array (asDataSeries) Source: https://github.com/polymathorg/dataframe/wiki/3.-Creating-DataSeries Shows how to create a DataSeries from any Smalltalk collection, such as an Array, using the `asDataSeries` extension method provided by the DataFrame library. This offers a convenient shortcut. ```smalltalk series := #(a b c) asDataSeries. ``` -------------------------------- ### Load Tipping Dataset Source: https://github.com/polymathorg/dataframe/wiki/11.-Aggregation-and-grouping Loads the Tipping dataset into a DataFrame object for analysis. This is the initial step before performing operations on the data. ```smalltalk df := DataFrame loadTips. ``` -------------------------------- ### Create DataFrame from Columns Source: https://github.com/polymathorg/dataframe/wiki/6.-Creating-DataFrame Initializes a DataFrame by providing data as an array of arrays, where each inner array represents a column. Row and column names are initialized to default values and can be set separately. ```smalltalk df := DataFrame fromColumns: #( ('Barcelona' 'Dubai' 'London') (1.609 2.789 8.788) (true true false)). df columnNames: #('City' 'Population' 'BeenThere'). df rowNames: #('A' 'B' 'C'). ``` -------------------------------- ### Create DataFrame from Matrix Source: https://github.com/polymathorg/dataframe/wiki/6.-Creating-DataFrame Initializes a DataFrame from a Matrix object. This method is useful when data is already structured in a matrix format, such as data read from XLSX files. ```smalltalk matrix := Matrix rows: 3 columns: 3 contents: #('Barcelona' 1.609 true 'Dubai' 2.789 true 'London' 8.788 false). df := DataFrame fromMatrix: matrix. ``` -------------------------------- ### Create DataFrame from Rows Source: https://github.com/polymathorg/dataframe/wiki/6.-Creating-DataFrame Initializes a DataFrame by passing data as an array of arrays, where each inner array represents a row. Row and column names are initialized to default values and can be set separately. ```smalltalk df := DataFrame fromRows: #( ('Barcelona' 1.609 true) ('Dubai' 2.789 true) ('London' 8.788 false)). df columnNames: #('City' 'Population' 'BeenThere'). df rowNames: #('A' 'B' 'C'). ``` -------------------------------- ### Read DataFrame from File Source: https://github.com/polymathorg/dataframe/wiki/6.-Creating-DataFrame Loads data into a DataFrame directly from CSV or XLSX files. For other formats like JSON, data must first be parsed into an array of rows before being passed to the DataFrame constructor. ```smalltalk DataFrame fromCSV: 'path/to/your/file.csv'. DataFrame fromXLSX: 'path/to/your/file.xlsx'. ``` -------------------------------- ### View First/Last Rows (Head/Tail) Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Preview the first or last 5 rows of a DataFrame using `head` and `tail` messages. These are shortcuts for selecting a range of rows and are useful for large datasets. ```Smalltalk df := DataFrame loadHousing. df head. df tail. ``` -------------------------------- ### Shortcut for Grouping DataFrame Columns Source: https://github.com/polymathorg/dataframe/wiki/11.-Aggregation-and-grouping Provides a convenient shortcut for grouping columns within the same DataFrame. This method simplifies the process of grouping one column by another. ```smalltalk tips group: #total_bill by: #sex. ``` -------------------------------- ### Transpose DataFrame Source: https://github.com/polymathorg/dataframe/blob/master/README.md Shows how to transpose a DataFrame, effectively swapping its rows and columns. This operation returns a new DataFrame. ```Smalltalk weather transposed. ``` -------------------------------- ### Select All Columns and Filter Rows with `selectAllWhere:` in Smalltalk Source: https://github.com/polymathorg/dataframe/wiki/10.-The-select:where:-queries This snippet shows how to filter rows based on specified conditions while retaining all original columns, analogous to `SELECT * WHERE` in SQL. The `selectAllWhere:` message takes a block with conditions that are applied to each row. Arguments within the block must match the DataFrame's column names. ```Smalltalk df selectAllWhere: [ :species :sepal_width | species = #setosa and: sepal_width = 3 ]. ``` -------------------------------- ### Declare DataFrame Dependency in Baseline Source: https://github.com/polymathorg/dataframe/blob/master/README.md This code snippet shows how to add the DataFrame library as a dependency in your Pharo project's baseline configuration. It specifies the repository to load the library from. ```Smalltalk spec baseline: 'DataFrame' with: [ spec repository: 'github://PolyMathOrg/DataFrame/src' ]. ``` -------------------------------- ### View Head/Tail of a DataSeries Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Apply `head:` and `tail:` messages to individual DataSeries objects, such as a specific column extracted from a DataFrame. This allows previewing subsets of series data. ```Smalltalk (df column: #LSTAT) head: 2. ``` -------------------------------- ### Select Columns and Filter Rows with `select:where:` in Smalltalk Source: https://github.com/polymathorg/dataframe/wiki/10.-The-select:where:-queries This snippet demonstrates how to select specific columns and filter rows from a DataFrame using the `select:where:` message. It requires an array of column names to include in the result and a block containing boolean conditions referencing column values for row filtering. The arguments in the block must correspond to the DataFrame's column names. ```Smalltalk df := DataFrame loadIris. df select: #(petal_width petal_length) where: [ :species :sepal_width | species = #setosa and: sepal_width = 3 ]. ``` -------------------------------- ### Complex Query: Select, Filter, Group, and Aggregate Source: https://github.com/polymathorg/dataframe/wiki/11.-Aggregation-and-grouping Illustrates a complex query involving selecting specific columns, filtering rows based on multiple conditions, grouping the results by a category, and applying an aggregation function (sum). ```smalltalk df select: #(sepal_length species) where: [ :petal_length :petal_width | (petal_length < 4.9 and: petal_length > 1.6) and: (petal_width < 0.4 or: petal_width > 1.5) ] groupBy: #species aggregate: #sum. ``` -------------------------------- ### Add Rows/Columns using at:put: in Smalltalk Source: https://github.com/polymathorg/dataframe/wiki/8.-Adding-new-rows-and-columns-to-DataFrame Adds new rows or columns to a DataFrame by assigning data to a non-existing key using the `at:put:` message. The DataFrame automatically appends the new key and associates it with the provided row or column data. This offers an alternative way to append data with explicit naming. ```smalltalk df at: #D put: #('Lviv' 0.724 true). df at: #Rating put: #(4 3 4). ``` -------------------------------- ### View Specific Number of First/Last Rows Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns View a specified number of the first or last rows of a DataFrame using the parametrized `head:` and `tail:` messages. This allows for flexible previewing of datasets. ```Smalltalk df head: 10. df tail: 3. ``` -------------------------------- ### Accessing DataSeries Elements by Key Source: https://github.com/polymathorg/dataframe/wiki/4.-Accessing-elements-of-DataSeries Shows how to access and modify DataSeries elements using key-based messages like `atKey:` and `atKey:put:`. This provides a way to interact with data using custom identifiers rather than just numerical indices. ```smalltalk series atKey: #k2. series atKey: #k3 put: 'x'. ``` -------------------------------- ### Accessing DataSeries Elements by Index Source: https://github.com/polymathorg/dataframe/wiki/4.-Accessing-elements-of-DataSeries Demonstrates accessing and modifying elements in a DataSeries using the `at:` and `at:put:` messages, similar to Array access. These methods allow direct access to elements based on their numerical position. ```smalltalk series at: 2. series at: 3 put: 'x'. ``` -------------------------------- ### Add Rows/Columns using named: methods in Smalltalk Source: https://github.com/polymathorg/dataframe/wiki/8.-Adding-new-rows-and-columns-to-DataFrame Appends new rows or columns to a DataFrame by providing a specific name for each. This method is useful when the sequence of names cannot be continued automatically. Requires a name for the new row or column. ```smalltalk df addRow: #('Lviv' 0.724 true) named: #D. df addColumn: #(4 3 4) named: #Rating. ``` -------------------------------- ### Add Element with Specific Key in DataSeries Source: https://github.com/polymathorg/dataframe/wiki/5.-Adding-new-elements-to-DataSeries Adds a new element to a DataSeries, associating it with a specified key. This method modifies the existing series and does not create a new one. ```Smalltalk series add: 'x' atKey: #k4. ``` -------------------------------- ### Transforming DataSeries with collect: Source: https://github.com/polymathorg/dataframe/wiki/4.-Accessing-elements-of-DataSeries Illustrates using the `collect:` message to create a new DataSeries by applying a transformation to each element. This operation preserves the name and keys of the original DataSeries, making it useful for data manipulation. ```smalltalk newSeries := series collect: [ :each | each, 'x' ]. newSeries name. newSeries atKey: 'k1'. ``` -------------------------------- ### Add Row to DataFrame Source: https://github.com/polymathorg/dataframe/blob/master/README.md Illustrates how to add a new row to an existing DataFrame. The new row is given a specific name (index). ```Smalltalk weather addRow: #(-1.2 true snow) named: 6. ``` -------------------------------- ### Access Multiple Columns/Rows by Name/Index Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Select multiple columns or rows simultaneously by providing an array of names or indexes, or by specifying a numeric range. The order of selection is preserved in the resulting DataFrame. ```Smalltalk df columns: #(City BeenThere). df rowsAt: #(3 1). df columnsFrom: 2 to: 3. df rowsFrom: 3 to: 1. ``` -------------------------------- ### Group Series by Another Series Source: https://github.com/polymathorg/dataframe/wiki/11.-Aggregation-and-grouping Demonstrates grouping one series (e.g., total_bill) by the unique values of another series (e.g., sex). The result is a grouped object that splits the data based on the grouping criteria. ```smalltalk bill := tips column: #total_bill. sex := tips column: #sex. bill groupBy: sex. ``` -------------------------------- ### Add or Modify Element at Key in DataSeries Source: https://github.com/polymathorg/dataframe/wiki/5.-Adding-new-elements-to-DataSeries Adds a new element associated with a key if the key does not exist, or modifies an existing element at the given key. This method modifies the existing series and does not create a new one. ```Smalltalk series atKey: #k4 put: 'x'. ``` -------------------------------- ### Access Row and Column by Name Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Access a specific row or column of a DataFrame by its name. The DataFrame object responds with a DataSeries object that preserves the original indexing. ```Smalltalk df row: 'C'. df column: 'Population'. ``` -------------------------------- ### Access Row and Column by Index Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Access a specific row or column of a DataFrame using its numeric index. Indexes are 1-based. The DataFrame object responds with a DataSeries object that preserves the original indexing. ```Smalltalk df rowAt: 3. df columnAt: 2. ``` -------------------------------- ### Update Row or Column Values Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Modify the values of a specific row or column by providing an array or series of the same size. These messages modify the DataFrame in place and should be used with caution. ```Smalltalk df column: #BeenThere put: #(false true false). ``` -------------------------------- ### Access Single Cell Value Source: https://github.com/polymathorg/dataframe/wiki/7.-Accessing-rows-and-columns Access or modify a single cell within the DataFrame using its row and column indexes. The `at:at:` message retrieves the value, while `at:at:put:` updates it. ```Smalltalk df at: 3 at: 2. df at: 3 at: 2 put: true. ``` -------------------------------- ### Remove Row from DataFrame Source: https://github.com/polymathorg/dataframe/blob/master/README.md Shows how to remove a specific row from a DataFrame by its index. This operation modifies the DataFrame in place. ```Smalltalk weather removeRowAt: 3. ``` -------------------------------- ### Update DataFrame Cell Value Source: https://github.com/polymathorg/dataframe/blob/master/README.md Demonstrates how to modify the value of a specific cell within the DataFrame using its row and column indices. The value is updated in place. ```Smalltalk weather at:1 at:3 put:#snow. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.