GithubHelp home page GithubHelp logo

Comments (6)

ashleydavis avatar ashleydavis commented on May 24, 2024

I'm not sure off the top of my head, I'll have to look up the Pandas reindex function to remember how it works. I'll get back to you in a couple of days.

Maybe you could describe to me the behavior you'd like to see in DataForge?

from data-forge-ts.

erictamhk avatar erictamhk commented on May 24, 2024

i implement this function by using javascript, i don't know am i do it right, but it work.
i find that the DataFrame.at() is very slow to get a row of data.

`dataForge.DataFrame.prototype.reindex = function(new_index, fill_value = null) {
let newArray = ["tempIndex"].concat(this.getColumnNames());
let pairs = this.toPairs();
let newIndexArray = new_index.toArray();
const dfIndexArray = this.getIndex().toArray();

const filterPairs = pairs.reduce(function(a, e, i) {
if (newIndexArray.indexOf(e[0]) >= 0) {
let obj = e[1];
let idx = e[0];
let newObj = {};
newArray.forEach(val => {
if (val === "tempIndex") {
newObj[val] = idx;
} else {
newObj[val] = obj[val];
}
});
a.push(newObj);
}
return a;
}, []);

const emptyPairs = newIndexArray.reduce(function(a, e, i) {
if (dfIndexArray.indexOf(e) === -1) {
let newObj = {};
newArray.forEach(val => {
if (val === "tempIndex") {
newObj[val] = e;
} else {
newObj[val] = fill_value;
}
});
a.push(newObj);
}
return a;
}, []);`

from data-forge-ts.

ashleydavis avatar ashleydavis commented on May 24, 2024

Reindex won't make at any faster.

Currently at doesn't even use the index. I'll re-write the function at some point so that uses the index.

from data-forge-ts.

shajeeck avatar shajeeck commented on May 24, 2024

@ashleydavis as you mentioned at doesn't use index, what is the function which uses index to return the row?

from data-forge-ts.

shajeeck avatar shajeeck commented on May 24, 2024

@ashleydavis Or is it already rewritten as i can see in the docs?
https://github.com/data-forge/data-forge-ts/blob/master/docs/guide.md#getting-a-row-or-value-by-index

from data-forge-ts.

ashleydavis avatar ashleydavis commented on May 24, 2024

The at function takes an index and returns the first value at that index.

The at function is not optimised, so it is quite slow (this can be fixed of course),

from data-forge-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.