pwwang / datar

A Grammar of Data Manipulation in python

Home Page:https://pwwang.github.io/datar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] relocate() with any_of() does not order column names correctly

GitHunter0 opened this issue · comments

datar version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of datar and its backends.

Issue Description

When a column (in this case 'x2') is not present, relocate() with any_of() does not respect the order passed.

import datar.all as d
from datar import f
import pandas as pd

df = pd.DataFrame({'x1': [1], 'x4': [4], 'x3': [3]})

df >> d.relocate(d.any_of(['x1', 'x2', 'x3', 'x4']))
#>        x1      x4      x3
  <int64> <int64> <int64>
0       1       4       3

Expected Behavior

The new order should be 'x1', 'x3', 'x4'

Installed Versions

python : 3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)]
datar : 0.11.1
simplug : 0.2.2
executing : 1.2.0
pipda : 0.11.0
datar-numpy : 0.1.0
numpy : 1.23.5
datar-pandas: 0.2.0
pandas : 1.5.2