npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-neutron-frame

v1.5.3

Published

Node project to have data manipulation and analysis, parallel to pandas

Downloads

3

Readme

LinkedIn

About The Project

"js-neutron-frame" is a powerful library written in TypeScript designed to provide data manipulation and statistical analysis capabilities, akin to Python's Pandas library, but tailored specifically for JavaScript/TypeScript and Node.js applications. The library offers a flexible and efficient way to work with tabular data, enabling developers to perform data transformations, statistical calculations, and more, all within the JavaScript ecosystem.

Key Features:

Data Manipulation: With "js-neutron-frame", you can effortlessly work with data in tabular format, treating it like a spreadsheet. The library supports adding, updating, and deleting rows and columns, making data manipulation a breeze.

Statistical Analysis: "js-neutron-frame" comes equipped with a rich set of statistical functions. Perform operations such as calculating mean, median, mode, and standard deviation on columns or the entire DataFrame, gaining valuable insights from your data.

Data Import and Export: Easily import data from CSV and Excel files, ensuring seamless integration with your existing datasets. The library empowers you to export results and processed data back to various file formats with ease.

Dynamic Column Handling: When using the addRow function, "DataFrame.js" dynamically adjusts columns based on the provided data. New columns are automatically created if the keys in the provided row data do not exist in the current columns.

Flexible and Lightweight: Built with modern JavaScript, "DataFrame.js" offers a lightweight and versatile solution for data analysis. It is optimized for speed and memory efficiency, making it suitable for both small and large datasets.

Easy Integration: As an npm module, "DataFrame.js" is readily available for integration into any JavaScript or Node.js project. Simply install the package and start harnessing its data manipulation capabilities right away.

Getting Started

This is walkthrough of how the library can be installed/

Prerequisites and Installation

  1. Install Node.js and npm
  2. For TypeScript projects, install TypeScript [This step is not required for JavaScript projects]
npm install typescript --save-dev
  1. Install the library from npm modules:
npm install js-neutron-frame

Documentation and Examples

import the library

import { DataFrame, readCSV } from "js-neutron-frame";

Create DataFrame

  1. Create an empty DataFrame:
const df = new DataFrame();

  1. Create DataFrame by reading from .csv file:
const df = await readCSV('./oscar_age_male.csv');

DataFrame utilities

  1. addRows(DataFrameRow): void The keys refer to the columns If a key is new, it is added to the columns
df.addRow({Index:1, Year: 1928, Age:44, Name:'Emil Jannings', Movie: 'The Last Command'});
df.addRow({Index:2, Year: 1929, Age:41, Name:'Warner Baxter', Movie: 'The Old Arizona'});
df.addRow({Index:3, Year: 1930, Age:62, Name:'George Arliss', Movie: 'Disraeli'});
df.addRow({Index:4, Year: 1931, Age:53, Name:'Lionel Barrymore', Movie: 'A Free Soul'});

  1. addColumns(name: string, values: (number | string | boolean)[]): void
const BoxOffice = [50000, 60000, 75000];
df.addColumn('BoxOffice', salaryData);

  1. getShape(): [row_size, column_size] returns the [rows, columns] of the DataFrame
df.getShape();

Output: [ 89, 5 ]


  1. filterByColums(columnName: string, value: number | string | boolean): DataFrameRow[] Takes columnName and the value that has to be matched as input. This does simple plain matching and returns the filtered rows.
df.filterByColumn('Age', 44)

Output:

[
  {
    Index: 1,
    Year: 1928,
    Age: 44,
    Name: 'Emil Jannings',
    Movie: 'The Last Command'
  },
  {
    Index: 87,
    Year: 2014,
    Age: 44,
    Name: 'Matthew McConaughey',
    Movie: 'Dallas Buyers Club'
  }
]

  1. showFirstRows(n: number = 5): DataFrameRow[] Shows n rows from beggining. Default 5 rows are shown if not specified.
const firstRows = df.showFirstRows(3);

Output:

[
  {
    Index: 1,
    Year: 1928,
    Age: 44,
    Name: 'Emil Jannings',
    Movie: 'The Last Command'
  },
  {
    Index: 2,
    Year: 1929,
    Age: 41,
    Name: 'Warner Baxter',
    Movie: 'In Old Arizona'
  },
  {
    Index: 3,
    Year: 1930,
    Age: 62,
    Name: 'George Arliss',
    Movie: 'Disraeli'
  }
]

  1. showLastRows(n: number = 5): DataFrameRow[] Shows n rows from last. Default 5 rows are shown if not specified.
const lastRows = df.showLastRows(2)

Output:

[
  {
    Index: 3,
    Year: 1930,
    Age: 62,
    Name: 'George Arliss',
    Movie: 'Disraeli'
  },
  {
    Index: 4,
    Year: 1931,
    Age: 53,
    Name: 'Lionel Barrymore',
    Movie: 'A Free Soul'
  }
]

  1. getColumnDataTypes(): { [key: string]: string } returns the data types of the columns based on their values
df.getColumnDataTypes();

Output:

{
  Index: 'number',
  Year: 'number',
  Age: 'number',
  Name: 'string',
  Movie: 'string'
}

Statistical Opeartions on the Data

For more examples, please refer to the google doc Documentation

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Krishna Rao - @KrishnaRaoBV - [email protected]

Project Link: https://github.com/krishnaatt/js-neutron-frame

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!