@@ -1591,4 +1591,58 @@ describe("Series Functions", () => {
15911591 assert . deepEqual ( sf . and ( data2 ) . index , expected ) ;
15921592 } ) ;
15931593 } ) ;
1594+
1595+ describe ( "iat" , function ( ) {
1596+ it ( "iat works on Series" , function ( ) {
1597+ const data = [ 1 , 2 , 3 , 4 ] ;
1598+ const index = [ "a" , "b" , "c" , "d" ] ;
1599+ const df = new Series ( data , { index } ) ;
1600+ assert . equal ( df . iat ( 0 ) , 1 ) ;
1601+ assert . equal ( df . iat ( 1 ) , 2 ) ;
1602+ assert . equal ( df . iat ( 2 ) , 3 ) ;
1603+ } ) ;
1604+ it ( "iat can return undefined" , function ( ) {
1605+ const data = [ 1 , undefined , null , NaN ] ;
1606+ const df = new Series ( data ) ;
1607+ assert . equal ( df . iat ( 1 ) , undefined ) ;
1608+ assert . equal ( df . iat ( 2 ) , null ) ;
1609+ /* @ts -ignore */
1610+ assert . equal ( isNaN ( df . iat ( 3 ) ) , true ) ;
1611+ } ) ;
1612+ it ( "throws error on string indices" , function ( ) {
1613+ const data = [ 1 , 2 , 3 , 4 ] ;
1614+ const index = [ "a" , "b" , "c" , "d" ] ;
1615+ const df = new Series ( data , { index } ) ;
1616+ /* @ts -ignore */
1617+ assert . throws ( function ( ) { df . iat ( "A" ) ; } , Error , "ParamError: row index must be an integer. Use .at to get a row by label." ) ;
1618+ } ) ;
1619+ } )
1620+
1621+ describe ( "at" , function ( ) {
1622+ it ( "at works on Series" , function ( ) {
1623+ const data = [ 1 , 2 , 3 , 4 ] ;
1624+ const index = [ "a" , "b" , "c" , "d" ] ;
1625+ const df = new Series ( data , { index } ) ;
1626+ assert . equal ( df . at ( "a" ) , 1 ) ;
1627+ assert . equal ( df . at ( "b" ) , 2 ) ;
1628+ assert . equal ( df . at ( "c" ) , 3 ) ;
1629+ } ) ;
1630+ it ( "at can return undefined" , function ( ) {
1631+ const data = [ 1 , undefined , null , NaN ] ;
1632+ const index = [ "a" , "b" , "c" , "d" ] ;
1633+ const df = new Series ( data , { index } ) ;
1634+ assert . equal ( df . at ( "b" ) , undefined ) ;
1635+ assert . equal ( df . at ( "c" ) , null ) ;
1636+ /* @ts -ignore */
1637+ assert . equal ( isNaN ( df . at ( "d" ) ) , true ) ;
1638+ } ) ;
1639+ it ( "throws error on string indices" , function ( ) {
1640+ const data = [ 1 , 2 , 3 , 4 ] ;
1641+ const index = [ "a" , "b" , "c" , "d" ] ;
1642+ const df = new Series ( data , { index } ) ;
1643+ /* @ts -ignore */
1644+ assert . throws ( function ( ) { df . at ( 0 ) ; } , Error , "ParamError: row index must be a string. Use .iat to get a row by index." ) ;
1645+ } ) ;
1646+
1647+ } ) ;
15941648} )
0 commit comments