{"id":15893041,"url":"https://github.com/hazelnutparadise/insyra","last_synced_at":"2026-01-03T07:19:53.676Z","repository":{"id":255350711,"uuid":"849316860","full_name":"HazelnutParadise/insyra","owner":"HazelnutParadise","description":"A next-generation data analysis library for Golang.","archived":false,"fork":false,"pushed_at":"2025-03-13T06:36:47.000Z","size":70082,"stargazers_count":27,"open_issues_count":8,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T07:32:20.061Z","etag":null,"topics":["analysis","data-science","data-visualization","glpk","go-echarts","golang","gonum","hacktoberfest","insyra","linear-programming","pandas","parallel","plot","python","r","seaborn","stats"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/HazelnutParadise/insyra","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HazelnutParadise.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-29T11:34:39.000Z","updated_at":"2025-03-13T06:30:42.000Z","dependencies_parsed_at":"2025-03-13T13:15:50.517Z","dependency_job_id":null,"html_url":"https://github.com/HazelnutParadise/insyra","commit_stats":null,"previous_names":["hazelnutparadise/insyra"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazelnutParadise%2Finsyra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazelnutParadise%2Finsyra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazelnutParadise%2Finsyra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HazelnutParadise%2Finsyra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HazelnutParadise","download_url":"https://codeload.github.com/HazelnutParadise/insyra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244058160,"owners_count":20391047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analysis","data-science","data-visualization","glpk","go-echarts","golang","gonum","hacktoberfest","insyra","linear-programming","pandas","parallel","plot","python","r","seaborn","stats"],"created_at":"2024-10-06T08:06:35.217Z","updated_at":"2026-01-03T07:19:53.670Z","avatar_url":"https://github.com/HazelnutParadise.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Insyra - Crafting Your Art of Data\n\n[![Test](https://github.com/HazelnutParadise/insyra/actions/workflows/test.yml/badge.svg)](https://github.com/HazelnutParadise/insyra/actions/workflows/test.yml)\n[![GolangCI-Lint](https://github.com/HazelnutParadise/insyra/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/HazelnutParadise/insyra/actions/workflows/golangci-lint.yml)\n[![Govulncheck](https://github.com/HazelnutParadise/insyra/actions/workflows/govulncheck.yml/badge.svg)](https://github.com/HazelnutParadise/insyra/actions/workflows/govulncheck.yml)\n[![Go version](https://img.shields.io/github/go-mod/go-version/HazelnutParadise/insyra.svg)](https://github.com/HazelnutParadise/insyra)\n[![Go Report Card](https://goreportcard.com/badge/github.com/HazelnutParadise/insyra)](https://goreportcard.com/report/github.com/HazelnutParadise/insyra)\n[![GoDoc](https://godoc.org/github.com/HazelnutParadise/insyra?status.svg)](https://pkg.go.dev/github.com/HazelnutParadise/insyra)\n[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\nA next-generation data analysis library for Golang. Supports **parallel processing**, **data visualization**, and **seamless integration with Python**.\n\n**Official Website: \u003chttps://insyra.hazelnut-paradise.com\u003e**\n\n**Documentation: \u003chttps://hazelnutparadise.github.io/insyra/\u003e**\n\n\u003e [!NOTE]\n\u003e This project is evolving rapidly—please star and watch the repository to stay up to date with the latest changes!\n\n![logo](logo/logo_transparent.png)\n\n**[繁體中文版 README](README_TW.md)**\n\nWelcome to join [**Side Project Taiwan**(Discord Server)](https://discord.com/channels/1205906503073140776/1280539658551558368) for further discussions.\n\n## Fast, Lovely, Easy To Use\n\nThe **Insyra** library is a dynamic and versatile tool designed for managing and analyzing data in Go. It offers a rich set of features for data manipulation, statistical calculations, data visualization, and more, making it an essential toolkit for developers handling complex data structures.\n\n\u003e [!TIP]\n\u003e We got brand new `isr` package, which provides **Sytax Sugar**!\u003cbr/\u003e\n\u003e Any new project is recommended to use `isr` package instead of calling `insyra` main package directly.\u003cbr/\u003e\n\u003e For more details, please refer to the **[Documentation](/Docs/isr.md)**.\n\n\u003e [!NOTE]\n\u003e If some functions or methods in the documentation are not working, it may be because the feature is not yet included in the latest release. Please refer to the documentation in the source code of the corresponding version in **[Releases](https://github.com/HazelnutParadise/insyra/releases)**.\n\n\u003e [!IMPORTANT]\n\u003e **For any functions or methods not explicitly listed in Insyra documents, it indicates that the feature is still under active development. These experimental features might provide unstable results.** \u003cbr/\u003e\n\u003e Please refer to our latest updates in **[Docs](/Docs)** folder for more details.\n\n## [Idensyra](https://github.com/HazelnutParadise/idensyra)\n\nWe provide a mini Go IDE, `Idensyra`, which aims to make data analysis even more easier (though Insyra has already made it very easy).\n\n`Idensyra` comes with Insyra pre-installed, and allows you to run Go code without installing Go environment!\n\n**[Know more about Idensyra](https://github.com/HazelnutParadise/idensyra)**\n\n## Getting Started\n\n### For those new to Golang\n\n\u003e [!TIP]\n\u003e Jump to [Installation](#installation) or [Quick Example](#quick-example) if you are familiar with Go.\n\n1. Download and install Golang from [here](https://golang.org/dl/).\n2. Set up your editor, we recommend using [VSCode](https://code.visualstudio.com/). Or even lighter weight, [Idensyra](https://github.com/HazelnutParadise/idensyra).\n3. Open or create a folder for your project, and open it in the editor.\n\n4. Create a new project by running the following command:\n\n    ```sh\n    go mod init your_project_name\n    ```\n\n5. Install **Insyra**:\n\n    ```sh\n    go get github.com/HazelnutParadise/insyra/allpkgs\n    ```\n\n6. Create a new file, e.g., `main.go`, and write the following code:\n\n    ```go\n    package main\n\n    import (\n        \"fmt\"\n        \"github.com/HazelnutParadise/insyra\"\n    )\n\n    func main() {\n        // Your code here\n    }\n    ```\n\n7. Run your project:\n\n    ```sh\n    go run main.go\n    ```\n\n### Installation\n\n- To start using **Insyra**, install it with the following command:\n\n    ```sh\n    go get github.com/HazelnutParadise/insyra/allpkgs\n    ```\n\n- Update **Insyra** to the latest version:\n\n    ```sh\n    go get -u github.com/HazelnutParadise/insyra/allpkgs\n    ```\n\n    or\n\n    ```sh\n    go get -u github.com/HazelnutParadise/insyra/allpkgs@latest\n    ```\n\n### Quick Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/HazelnutParadise/insyra\"\n)\n\nfunc main() {\n    dl := insyra.NewDataList(1, 2, 3, 4, 5)\n    dl.Append(6)\n    fmt.Println(\"DataList:\", dl.Data())\n    fmt.Println(\"Mean:\", dl.Mean())\n}\n```\n\n#### Syntactic Sugar\n\nIt is strongly recommended to use syntactic sugar since it is much more power and easier to use. For example, the above code can be written as:\n\n```go\npackage main\n\nimport (\n \"fmt\"\n\n \"github.com/HazelnutParadise/insyra/isr\"\n)\n\nfunc main() {\n dl := isr.DL.Of(1, 2, 3, 4, 5)\n dl.Append(6)\n dl.Show()\n fmt.Println(\"Mean:\", dl.Mean())\n}\n```\n\nTo use the syntactic sugar, import `github.com/HazelnutParadise/insyra/isr`.\n\n### Console Preview with `insyra.Show`\n\nNeed a quick labelled look at any showable structure (like `DataTable` or `DataList`)? Use the package-level `Show` helper, which delegates to `ShowRange` under the hood and supports the same range arguments:\n\n```go\nfunc main() {\n    dt := insyra.NewDataTable(\n        insyra.NewDataList(\"Alice\", \"Bob\", \"Charlie\").SetName(\"Name\"),\n        insyra.NewDataList(28, 34, 29).SetName(\"Age\"),\n    ).SetName(\"Team Members\")\n\n    insyra.Show(\"Preview\", dt, 2) // First two rows\n}\n```\n\n### Configuration\n\n**Insyra** provides a global `Config` object for managing library behavior. You can customize logging, error handling, and performance settings:\n\n#### Log Level Management\n\nControl what level of messages are logged:\n\n```go\n// Set log level - only messages at this level or above will be logged\ninsyra.Config.SetLogLevel(insyra.LogLevelDebug)    // Most verbose\ninsyra.Config.SetLogLevel(insyra.LogLevelInfo)     // Default\ninsyra.Config.SetLogLevel(insyra.LogLevelWarning)  // Only warnings and errors\ninsyra.Config.SetLogLevel(insyra.LogLevelFatal)    // Only fatal errors\n\n// Get current log level\nlevel := insyra.Config.GetLogLevel()\n```\n\n#### Colored Output\n\nControl whether terminal output is colored:\n\n```go\n// Enable / disable colored output\ninsyra.Config.SetUseColoredOutput(true)\n\n// Check colored output status\nusesColor := insyra.Config.GetDoesUseColoredOutput()\n```\n\n#### Error Handling\n\nConfigure how errors are handled:\n\n```go\n// Prevent panics and handle errors gracefully instead\ninsyra.Config.SetDontPanic(true)\n\n// Check panic prevention status\nisPanicPrevented := insyra.Config.GetDontPanicStatus()\n\n// Set custom error handling function for all errors\ninsyra.Config.SetDefaultErrHandlingFunc(func(errType insyra.LogLevel, packageName, funcName, errMsg string) {\n    // Your custom error handling logic\n    // errType: The severity level of the error\n    // packageName: The package where the error occurred\n    // funcName: The function where the error occurred\n    // errMsg: The error message\n    // Use %v to print LogLevel values reliably\n    fmt.Printf(\"[%v] %s.%s: %s\\n\", errType, packageName, funcName, errMsg)\n})\n\n// Get the current error handling function\nhandler := insyra.Config.GetDefaultErrHandlingFunc()\n```\n\n#### Performance Configuration\n\nFine-tune performance for your use case:\n\n```go\n// ⚠️ DANGER: Turn off thread safety for extreme performance\n// Use ONLY when you are sure there are no concurrent accesses\n// Data consistency is NOT guaranteed when this is disabled!\ninsyra.Config.Dangerously_TurnOffThreadSafety()\n\n// If you need to reset all configs back to library defaults, call:\n// Note: defaults are usually set on initialization, but this can be\n// useful during tests or when switching configurations at runtime.\ninsyra.SetDefaultConfig()\n```\n\n#### Complete Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/HazelnutParadise/insyra\"\n)\n\nfunc main() {\n    // Initialize with custom configuration\n    insyra.Config.SetLogLevel(insyra.LogLevelDebug)\n    insyra.Config.SetDontPanic(true)\n    \n    // Custom error handler\n    insyra.Config.SetDefaultErrHandlingFunc(func(errType insyra.LogLevel, pkg, fn, msg string) {\n        fmt.Printf(\"ERROR in %s.%s: %s\\n\", pkg, fn, msg)\n    })\n    \n    // Now use Insyra with these settings\n    dl := insyra.NewDataList(1, 2, 3, 4, 5)\n    fmt.Println(dl.Mean())\n}\n```\n\nFor implementation details, see the [config.go](config.go) source file.\n\n## Thread Safety and Defensive Copies\n\n- **Defensive copies:** Insyra returns defensive copies for all public data accessors. Any method that exposes internal slices, maps, or other mutable structures returns a copy so callers cannot mutate internal state unintentionally.\n- **Atomic operations:** For safe concurrent multi-step operations, use the helper `AtomicDo`. `AtomicDo` serializes all operations for an instance via a dedicated actor goroutine and a command channel (see [atomic.go](atomic.go)), avoiding mutexes.\n\n## [DataList](/Docs/DataList.md)\n\nThe `DataList` is the core structure in **Insyra**, enabling the storage, management, and analysis of dynamic data collections. It offers various methods for data manipulation and statistical analysis.\n\nFor a complete list of methods and features, please refer to the **[DataList Documentation](/Docs/DataList.md)**.\n\n## [DataTable](/Docs/DataTable.md)\n\nThe `DataTable` structure provides a tabular data representation, allowing for the storage and manipulation of data in a structured format. It offers methods for data filtering, sorting, and aggregation, making it a powerful tool for data analysis.\n\n**You can also convert between DataTables and CSV files with simply one line of code, enabling seamless integration with external data sources.**\n\n### [Column Calculation Language (CCL)](/Docs/CCL.md)\n\n**Insyra** features a powerful **Column Calculation Language (CCL)** that works just like Excel formulas!\n\nWith CCL, you can:\n\n- Create calculated columns using familiar Excel-like syntax\n- Reference columns using Excel-style notation (A, B, C...)\n- Use conditional logic with `IF`, `AND`, `OR`, and `CASE` functions\n- Perform mathematical operations and string manipulations\n- Execute chained comparisons like `1 \u003c A \u003c= 10` for range checks\n- Access specific rows using the `.` operator (e.g., `A.0`) and reference all columns with `@`\n- Use aggregate functions like `SUM`, `AVG`, `COUNT`, `MAX`, and `MIN`\n\n```go\n// Add a column that classifies data based on values in column A\ndt.AddColUsingCCL(\"category\", \"IF(A \u003e 90, 'Excellent', IF(A \u003e 70, 'Good', 'Average'))\")\n\n// Perform calculations just like in Excel\ndt.AddColUsingCCL(\"total\", \"A + B + C\")\ndt.AddColUsingCCL(\"average\", \"AVG(A + B + C)\")\n\n// Use aggregate functions on rows or columns\ndt.AddColUsingCCL(\"row_sum\", \"SUM(@.0)\")\n\n// Use range checks with chained comparisons (try this in Excel!)\ndt.AddColUsingCCL(\"in_range\", \"IF(10 \u003c= A \u003c= 20, 'Yes', 'No')\")\n```\n\n#### Parquet Integration\n\nCCL can be applied **directly during Parquet file reading** to filter data at the source:\n\n```go\n// Filter rows while reading - only matching rows are loaded into memory\ndt, err := parquet.FilterWithCCL(ctx, \"sales_data.parquet\", \"(['amount'] \u003e 1000) \u0026\u0026 (['status'] = 'Active')\")\n\n// Apply CCL transformations directly on parquet files (streaming mode)\nerr := parquet.ApplyCCL(ctx, \"data.parquet\", \"NEW('total') = A + B + C\")\n```\n\nThis approach reduces memory usage when working with large datasets by processing data in batches.\n\nFor a complete guide to CCL syntax and features, see the **[CCL Documentation](/Docs/CCL.md)**.\n\nFor a complete list of DataTable methods and features, please refer to the **[DataTable Documentation](/Docs/DataTable.md)**.\n\n## Packages\n\n**Insyra** also provides several expansion packages, each focusing on a specific aspect of data analysis.\n\n### **[isr](/Docs/isr.md)**\n\nProvides **Syntactic Sugar** for **Insyra**. It is designed to simplify the usage of **Insyra** and make it more intuitive.\n\n### **[stats](/Docs/stats.md)**\n\nProvides statistical functions for data analysis, including skewness, kurtosis, and moment calculations.\n\n### **[parallel](/Docs/parallel.md)**\n\nOffers parallel processing capabilities for data manipulation and analysis. Allows you to execute any function and automatically wait for all goroutines to complete.\n\n### **[plot](/Docs/plot.md)**\n\nProvides a wrapper around the powerful [github.com/go-echarts/go-echarts](https://github.com/go-echarts/go-echarts) library, designed to simplify data visualization.\n\n### **[gplot](/Docs/gplot.md)**\n\nA visualization package based on [github.com/gonum/plot](https://github.com/gonum/plot). Fast and no need for Chrome. Even supports function plot.\n\n### **[csvxl](/Docs/csvxl.md)**\n\nWork with Excel and CSV files. Such as convert CSV to Excel.\n\n### **[parquet](/Docs/parquet.md)**\n\nProvides read and write support for the Apache Parquet file format, deeply integrated with Insyra's `DataTable` and `DataList`. Supports streaming, column-level reading, and CCL filtering.\n\n### **[mkt](/Docs/mkt.md)**\n\nProvides marketing-related data analysis functions, such as RFM analysis. No need to worry about how to calculate, one function does it all!\n\n### **[py](/Docs/py.md)**\n\nExecute Python code in Go without manually installing Python environment and dependencies. Allows passing variables between Go and Python.\n\n### **[datafetch](/Docs/datafetch.md)**\n\nAllows you to fetch data easily. It currently supports fetching comments from stores on Google Maps.\n\n### **[lpgen](/Docs/lpgen.md)**\n\nProvides a **super simple** and intuitive way to generate linear programming (LP) models and save them as `.lp` files. It supports setting objectives, adding constraints, defining variable bounds, and specifying binary or integer variables.\n\n### **[lp](/Docs/lp.md)**\n\nFully automatic linear programming (LP) solver using [GLPK](https://www.gnu.org/software/glpk/).\n\n## Advanced Usage\n\nBeyond basic usage, **Insyra** provides extensive capabilities for handling different data types and performing complex statistical operations. Explore more in the **[detailed documentation](/Docs)**.\n\n## Contributing\n\nContributions are welcome! You can contribute to **Insyra** by:\n\n- **[Issues](https://github.com/HazelnutParadise/insyra/issues):** Reporting issues or suggesting new features.\n- **[Pull Requests](https://github.com/HazelnutParadise/insyra/pulls):** Submitting pull requests to enhance the library.\n- **[Discussions](https://github.com/HazelnutParadise/insyra/discussions):** Sharing your feedback and ideas to improve the project.\n\u003c!-- For more details, see the [contributing guidelines](https://github.com/HazelnutParadise/insyra/blob/main/CONTRIBUTING.md). --\u003e\n\n## Contributors\n\n[![contributors](https://contrib.rocks/image?repo=HazelnutParadise/insyra)](https://github.com/HazelnutParadise/insyra/contributors)\n\n## License\n\nInsyra is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazelnutparadise%2Finsyra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazelnutparadise%2Finsyra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazelnutparadise%2Finsyra/lists"}