Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming a column prevents from getting it later #295

Closed
undavide opened this issue Oct 14, 2021 · 2 comments · Fixed by #320
Closed

Renaming a column prevents from getting it later #295

undavide opened this issue Oct 14, 2021 · 2 comments · Fixed by #320
Assignees

Comments

@undavide
Copy link

Describe the bug
If I rename a column it's then impossible to get it

To Reproduce

const dfd = require("danfojs-node");
let data = {
  "A": [-20, 30, 47.3],
  "B": [34, -4, 5],
  "C": [20, 2, 30]
}
let df = new dfd.DataFrame(data); 

df.print(); // OK
// ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
// ║            │ A                 │ B                 │ C                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 0          │ -20               │ 34                │ 20                ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 1          │ 30                │ -4                │ 2                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 2          │ 47.3              │ 5                 │ 30                ║
// ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝


df["A"].print(); // OK, I can get the column "A"
// ╔═══╤══════╗
// ║ 0 │ -20  ║
// ╟───┼──────╢
// ║ 1 │ 30   ║
// ╟───┼──────╢
// ║ 2 │ 47.3 ║
// ╚═══╧══════╝

df.rename({ mapper: { "A": "new_name" }, inplace: true }); 
df.print(); // OK, the rename has been successful

// ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
// ║            │ new_name          │ B                 │ C                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 0          │ -20               │ 34                │ 20                ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 1          │ 30                │ -4                │ 2                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 2          │ 47.3              │ 5                 │ 30                ║
// ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

df["new_name"].print(); // :-(
// Uncaught TypeError: Cannot read properties of undefined (reading 'print')

console.log(df["new_name"] === undefined) // true?!

The column is now inaccessible, I can't reference it via "new_name", nor the old "A"

Expected behavior
df["new_name"] should return the same column the old name provided

Desktop (please complete the following information):

  • OS: macOS 10.15.7
  • Node.js: v16.11.1
  • Danfo: 0.3.2

Thank you!

@risenW
Copy link
Member

risenW commented Oct 14, 2021

Describe the bug If I rename a column it's then impossible to get it

To Reproduce

const dfd = require("danfojs-node");
let data = {
  "A": [-20, 30, 47.3],
  "B": [34, -4, 5],
  "C": [20, 2, 30]
}
let df = new dfd.DataFrame(data); 

df.print(); // OK
// ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
// ║            │ A                 │ B                 │ C                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 0          │ -20               │ 34                │ 20                ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 1          │ 30                │ -4                │ 2                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 2          │ 47.3              │ 5                 │ 30                ║
// ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝


df["A"].print(); // OK, I can get the column "A"
// ╔═══╤══════╗
// ║ 0 │ -20  ║
// ╟───┼──────╢
// ║ 1 │ 30   ║
// ╟───┼──────╢
// ║ 2 │ 47.3 ║
// ╚═══╧══════╝

df.rename({ mapper: { "A": "new_name" }, inplace: true }); 
df.print(); // OK, the rename has been successful

// ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
// ║            │ new_name          │ B                 │ C                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 0          │ -20               │ 34                │ 20                ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 1          │ 30                │ -4                │ 2                 ║
// ╟────────────┼───────────────────┼───────────────────┼───────────────────╢
// ║ 2          │ 47.3              │ 5                 │ 30                ║
// ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

df["new_name"].print(); // :-(
// Uncaught TypeError: Cannot read properties of undefined (reading 'print')

console.log(df["new_name"] === undefined) // true?!

The column is now inaccessible, I can't reference it via "new_name", nor the old "A"

Expected behavior df["new_name"] should return the same column the old name provided

Desktop (please complete the following information):

  • OS: macOS 10.15.7
  • Node.js: v16.11.1
  • Danfo: 0.3.2

Thank you!

Oh interesting. Thanks I'll fix this ASAP.

@undavide Here's an alternative way to the get the column in the meantime:

df.column("new_name").print();

@risenW risenW self-assigned this Oct 14, 2021
@risenW
Copy link
Member

risenW commented Dec 5, 2021

FIXED

@risenW risenW closed this as completed Dec 5, 2021
@risenW risenW mentioned this issue Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants