JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 20
  • Score
    100M100P100Q41784F

Package Exports

  • jspandas
  • jspandas/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jspandas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JsPandas

JsPandas is a lightweight JavaScript library for data manipulation and analysis, inspired by the popular pandas library in Python. It provides flexible data structures and data analysis tools similar to pandas, enabling efficient data handling and manipulation in JavaScript.

Features

  • Read and write data from/to CSV, Excel, TSV, and JSON files
  • Data manipulation functions such as filtering, sorting, grouping, and aggregating
  • Apply functions to columns or rows
  • Iterate over rows with iterrows method
  • Descriptive statistics

Installation

You can install JsPandas using npm:

npm install jspandas

Usage

Reading and Writing Data

    const { Pandas } = require('jspandas');

    // Read data from CSV file
    const df = await Pandas.readCSV('data.csv');
    console.log(df);

    // Read data from Excel file
    const df = await Pandas.readExcel('data.xlsx', 'Sheet1');
    console.log(df);

    // Read data from TSV file
    const df = await Pandas.readTSV('data.tsv');
    console.log(df);

    // Read data from JSON file
    const df = await Pandas.readJSON('data.json');
    console.log(df);


    await df.toCSV('output.csv');

    // Write data to Excel file
    await df.toEXCEL('output.xlsx');

    // Write data to JSON file
    await df.toJSON('output.json');

Applying Functions

    const { DataFrame } = require('jspandas');

    // Create some sample data
    const data = [
    { col1: 1, col2: 2, col3: 3 },
    { col1: 4, col2: 5, col3: 6 },
    { col1: 7, col2: 8, col3: 9 }
    ];

    const df = new DataFrame(data);

    // Apply function to columns
    const dfColumnsApplied = df.apply(value => value * 2, 0);
    console.log(dfColumnsApplied.toString());

    // Apply function to rows
    const dfRowsApplied = df.apply(row => {
    row['colSum'] = row['col1'] + row['col2'];
    return row;
    }, 1);
    console.log(dfRowsApplied.toString());