From 7c3f273bbc3266d846e139fde34942eb8798393e Mon Sep 17 00:00:00 2001 From: Jun Date: Thu, 13 Nov 2025 03:11:08 +1030 Subject: [PATCH] Fixed loc with one row cause error Fixes #597 --- src/danfojs-base/core/indexing.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/danfojs-base/core/indexing.ts b/src/danfojs-base/core/indexing.ts index 5c2b668b..c22c6797 100644 --- a/src/danfojs-base/core/indexing.ts +++ b/src/danfojs-base/core/indexing.ts @@ -243,7 +243,10 @@ export function _loc({ ndFrame, rows, columns }: { if (rows[0].startsWith(`"`) || rows[0].startsWith(`'`) || rows[0].startsWith("`")) { temp = _index.indexOf(rows[0].replace(/['"`]/g, '')) } else { - temp = _index.indexOf(Number(rows[0])) + temp = _index.indexOf(rows[0]); + if (temp === -1 && !isNaN(Number(rows[0]))) { + temp = _index.indexOf(Number(rows[0])); + } } if (temp === -1) { @@ -417,4 +420,4 @@ export function _loc({ ndFrame, rows, columns }: { } -} \ No newline at end of file +}