hosseinmoein / DataFrame

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types and contiguous memory storage
https://hosseinmoein.github.io/DataFrame/
BSD 3-Clause "New" or "Revised" License
2.46k stars 310 forks source link

about get last row and get_data_by_loc #171

Closed xkungfu closed 2 years ago

xkungfu commented 2 years ago

in pandas , df.iloc[-1] will get the last row. when I use get_data_by_idx, the range can't be set to negative. and when use get_data_by_loc {-1}, the application throw error: DataFrame::get_data_by_loc(): ERROR: Bad begin, end range: 64, 0 and when use get_data_by_loc {-10, -1} , the last row not in result.

so, can you set "-1" to last row?

hosseinmoein commented 2 years ago

get_data_by_idx() is not suitable for your purpose. See docs for how to use it

In case of get_data_by_loc () also see docs and code samples. It is implemented to have Python-like indexing behavior. But, you can not just specify one value for Index2D -- see docs. Yes, -1 should point to the last element. If you see the docs for get_data_by_loc (), I have a code sample for that. Let me know if you see a bug.

xkungfu commented 2 years ago

according to the doc, I saw the last row is not in range -1. did I miss something?

the doc: https://htmlpreview.github.io/?https://github.com/hosseinmoein/DataFrame/blob/master/docs/HTML/get_data_by_loc.html

MyDataFrame df4 = df.get_data_by_loc<double>(Index2D<long> { -4, -1 }); the output of df4 is:

df4: 
INDEX:3:<ulong>:123450,123455,123450,
col_1:3:<double>:4,5,6,
col_2:3:<double>:11,12,13,
col_3:3:<double>:18,19,20,
col_4:3:<double>:25,nan,nan,

but the last row data is: "123449 7 14 21 nan", the data is not in df4.

does the row we talk about is the same row about the last row?

hosseinmoein commented 2 years ago

I will take a look

hosseinmoein commented 2 years ago

I found the problem. I will fix it over the weekend

xkungfu commented 2 years ago

OK, thank you!

hosseinmoein commented 2 years ago

@xkungfu , the fix is released to master