{"id":15099877,"url":"https://github.com/adwaith-rajesh/ziframe","last_synced_at":"2026-01-07T01:33:01.520Z","repository":{"id":244816884,"uuid":"815508264","full_name":"Adwaith-Rajesh/ziframe","owner":"Adwaith-Rajesh","description":"A minimal DataFrame library in zig","archived":false,"fork":false,"pushed_at":"2024-06-17T17:10:55.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T16:55:57.107Z","etag":null,"topics":["dataframe","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/Adwaith-Rajesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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-06-15T11:18:27.000Z","updated_at":"2024-06-18T09:25:43.000Z","dependencies_parsed_at":"2024-06-17T17:10:29.692Z","dependency_job_id":"f812056d-d118-46b9-9bf9-fbedb3c8b076","html_url":"https://github.com/Adwaith-Rajesh/ziframe","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"aba33768629e24836fc954ff441cc4a194888c42"},"previous_names":["adwaith-rajesh/ziframe"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fziframe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fziframe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fziframe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fziframe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adwaith-Rajesh","download_url":"https://codeload.github.com/Adwaith-Rajesh/ziframe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245892080,"owners_count":20689444,"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":["dataframe","zig","ziglang"],"created_at":"2024-09-25T17:28:32.823Z","updated_at":"2026-01-07T01:33:01.484Z","avatar_url":"https://github.com/Adwaith-Rajesh.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ziframe\n\nA minimal 'DataFrame' library in zig.\n\nIn it's current form it can only perform basic operations such as\n\n- add rows\n- add columns\n- read from CSV file\n- removing rows/cols (using fromDF())\n- apply a function over the DataFrame\n- get shape\n\n---\n\n### Why\n\n- It's part of something big.\n- I wanted a way to read CSV files in zig in a proper way\n\n---\n\n### Usage\n\n#### Building\n\n- `build.zig.zon`\n\n```zig\n.{\n    ...\n    .dependencies = .{\n        .ziframe = .{\n            .url = \"https://github.com/Adwaith-Rajesh/ziframe/archive/refs/tags/v0.1.0.tar.gz\",\n            .hash = \"you know how to get this :)\",\n        }\n    }\n    ...\n}\n```\n\n- `build.zig`\n\n```zig\npub fn build(b: *std.Build) void {\n    ...\n\n    const ziframe = b.dependency(\"ziframe\", .{\n        .optimize = optimize,\n        .target = target,\n    });\n\n    const your_exe = b.addExecutable(.{\n        .name = \"you_exe\",\n        .root_source_file = b.path(\"path/to/source_file.zig\"),\n        .target = target,\n        .optimize = optimize,\n    });\n\n    // add ziframe import\n    your_exe.root_module.addImport(\"ziframe\", ziframe.module(\"ziframe\"));\n\n    ...\n\n}\n\n```\n\n### Using Ziframe\n\n- `test.csv`\n\n```csv\nid,marks1,marks2\n1,10.23,20.45\n2,12.90,33.45\n3,46,50\n```\n\n- `main.zig`\n\n```zig\nconst std = @import(\"std\");\nconst debug = std.debug;\n\nconst zf = @import(\"ziframe\");\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer gpa.deinit()\n\n    const alloc = gpa.allocator();\n\n    // The columns of the DataFrame\n    const DFColumns = struct {\n        id: u32,\n        marks1: f64,\n        marks2: f64,\n    };\n\n    // Create an empty DataFrame\n    // var df = zf.DataFrame(Columns).init(alloc);\n    // defer df.deinit();\n\n    // read test.csv a create a new DataFrame\n    var df = try zf.DataFrame(DFColumns).fromCSV(alloc, \"./test.csv\", .{});\n    defer df.deinit();\n\n    debug.print(\"CSV file contents\\n\", .{});\n    debug.print(\"{}\\n\", .{df});\n\n    // adding a new row\n    try df.append(.{ .id = 4, .marks1 = 10, .marks2 = 20 });\n    debug.print(\"Add new row\\n\", .{});\n    debug.print(\"{}\\n\", .{df});\n\n    // Create a new DF with id and total marks from 'df'\n    const TotalDFCols = struct {\n        id: u32,\n        total: f64,\n    };\n\n    // function on how to create the new df\n    const total = struct {\n        fn in(row: DFColumns) ?TotalDFCols {\n            return .{\n                .id = row.id,\n                .total = row.marks1 + row.marks2,\n            };\n        }\n    }.in;\n\n    var total_df = try zf.DataFrame(TotalDFCols).fromDF(alloc, DFColumns, df, total);\n    defer total_df.deinit();\n\n    debug.print(\"New DataFrame with the total columns\\n\", .{});\n    debug.print(\"{}\\n\", .{total_df});\n\n    // filtering\n    // filter DataFrame, display only even ids\n\n    const filterEven = struct {\n        fn in(row: TotalDFCols) ?TotalDFCols {\n            if (row.id % 2 != 0) return null;\n            return row;\n        }\n    }.in;\n\n    var even_df = try zf.DataFrame(TotalDFCols).fromDF(alloc, TotalDFCols, total_df, filterEven);\n    defer even_df.deinit();\n\n    debug.print(\"DataFrame with only even ids\\n\", .{});\n    debug.print(\"{}\\n\", .{even_df});\n\n    // printing the shape and size\n    debug.print(\"shape of df: {} size of df: {}\\n\", .{ df.shape(), df.shape().size() });\n    debug.print(\"shape of total_df: {} size of df: {}\\n\", .{ total_df.shape(), total_df.shape().size() });\n    debug.print(\"shape of even_df: {} size of df: {}\\n\", .{ even_df.shape(), even_df.shape().size() });\n\n    // Map Function\n    // set total = 50 where id = 2\n    const update = struct {\n        //             pointer to the row\n        pub fn in(row: *TotalDFCols) !void {\n            if (row.*.id == 2) {\n                row.*.total = 50;\n            }\n        }\n    }.in;\n\n    try even_df.map(update);\n    debug.print(\"\\nset total = 50 where id = 2\\n\", .{});\n    debug.print(\"{}\\n\", .{even_df});\n}\n\n```\n\n- output\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/summary\u003e\n\n```commandline\n\nCSV file contents\nindex id marks1 marks2\n0  1 10.2300000  20.4500000\n1  2 12.9000000  33.4500000\n2  3 46.0000000  50.0000000\n\nAdd new row\nindex id marks1 marks2\n0  1 10.2300000  20.4500000\n1  2 12.9000000  33.4500000\n2  3 46.0000000  50.0000000\n3  4 10.0000000  20.0000000\n\nNew DataFrame with the total columns\nindex id total\n0  1 30.6800000\n1  2 46.3500000\n2  3 96.0000000\n3  4 30.0000000\n\nDataFrame with only even ids\nindex id total\n0  2 46.3500000\n1  4 30.0000000\n\nshape of df: 4x3 size of df: 12\nshape of total_df: 4x2 size of df: 8\nshape of even_df: 2x2 size of df: 4\n\nset total = 50 where id = 2\nindex id total\n0  2 50.0000000\n1  4 30.0000000\n```\n\n\u003c/details\u003e\n\n---\n\n### More docs in the future - maybe :)\n\n### Bye..","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwaith-rajesh%2Fziframe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadwaith-rajesh%2Fziframe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwaith-rajesh%2Fziframe/lists"}