stata sfi.Data举例

sysuse auto
python
from sfi import Data
dataraw = Data.get('foreign')
dataraw
end
// . python
// ----------------------------------------------- python (type end to exit) --------------------------------------------------------------------------------------------------------------------------------------------------------------------
// >>> from sfi import Data
// >>> dataraw = Data.get('foreign')
// >>> dataraw
// [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
// >>> end
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

python
from sfi import Data
dataraw = Data.get('foreign mpg rep78',range(46,56))
dataraw
end

// . python
// ----------------------------------------------- python (type end to exit) --------------------------------------------------------------------------------------------------------------------------------------------------------------------
// >>> from sfi import Data
// >>> dataraw = Data.get('foreign mpg rep78',range(46,56))
// >>> dataraw
// [[0, 18, 4], [0, 18, 1], [0, 19, 3], [0, 19, 3], [0, 19, 8.98846567431158e+307], [0, 24, 2], [1, 17, 5], [1, 23, 3], [1, 25, 4], [1, 23, 4]]
// >>> end
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



generate touse = mpg<20
python
from sfi import Data
dataraw = Data.get('foreign mpg rep78',range(46,56),"touse")
dataraw
end

//
// . python
// ----------------------------------------------- python (type end to exit) --------------------------------------------------------------------------------------------------------------------------------------------------------------------
// >>> from sfi import Data
// >>> dataraw = Data.get('foreign mpg rep78',range(46,56),"touse")
// >>> dataraw
// [[0, 18, 4], [0, 18, 1], [0, 19, 3], [0, 19, 3], [0, 19, 8.98846567431158e+307], [1, 17, 5]]
// >>> end
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//



python
from sfi import Data
dataraw = Data.get('foreign mpg rep78',range(46,56),"touse",valuelabel=True)
dataraw
end

//
// . python
// ----------------------------------------------- python (type end to exit) --------------------------------------------------------------------------------------------------------------------------------------------------------------------
// >>> from sfi import Data
// >>> dataraw = Data.get('foreign mpg rep78',range(46,56),"touse",valuelabel=True)
// >>> dataraw
// [['Domestic', 18, 4], ['Domestic', 18, 1], ['Domestic', 19, 3], ['Domestic', 19, 3], ['Domestic', 19, 8.98846567431158e+307], ['Foreign', 17, 5]]
// >>> end

 

posted @ 2023-04-24 15:53  myrj  阅读(20)  评论(0编辑  收藏  举报