Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    datio 0.0.1

    Download button

    No screenshots available
    Downloads: 98  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Mike Taylor | More programs
    MIT/X Consortium Lic... / FREE
    February 14th, 2012, 17:23 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    datio description

    The datio library in Python

    datio is data processing Python library useful in simulation work.

    The main class, Series, was designed to access data by rows or columns.

    Series is useful in simulation work where you need to process each row of data while analyzing the last x items for a given column.

    For example, in stock simulations, you'll iterate through all the prices for a stock but for each price period calculate the 20 period moving average of the closing price. The class, Series, makes the work of reading by rows while processing columns easy.

    Overview

    The major functions of datio:

    - Series():

     Access data across rows or columns. Append by rows or columns. Update Series in place.

    - lol2dol():

     convert a list of lists to dict of lists. Basically move from accessing data by rows to accessing data by columns.

    - csv2lol():

     load data from a csv file to a list of lists.

    - format_values():

     convert a list of values from one type to another such as float, int, string, or datatime.strptime.

    Usage

    Import the library:

     >>> import datio

    Define some data to work with:

     >>> prices_lol = []
     >>> prices_lol.append(['1997-01-01', 'goog', '32.00'])
     >>> prices_lol.append(['1997-01-02', 'goog', '33.00'])
     >>> prices_lol.append(['1997-01-03', 'goog', '34.00'])


    Load the data into your series:

     >>> series = datio.Series('dates', 'symbols', 'closes')
     >>> series.from_values(prices_lol)


    Access all the dates in the series:

     >>> series.dates
     ['1997-01-01', '1997-01-02', '1997-01-03']


    Access only the 2nd row of the series:

     >>> series[1]
     ('1997-01-02', 'goog', '33.00')


    Access the 1st row of the series for the closes column:

     >>> series.closes[0]
     '32.00'


    Format the closes column to float:

     >>> series.format('closes', float)
     [32.0, 33.0, 34.0]


    We'd like to include price opens as well. So, append opens to series:

     >>> series.appendcol('opens', [31.00, 33.0, 35])
     >>> series.opens
     [31.0, 33.0, 35]


    We'll probably need a column for storing moving averages later on:

     >>> series.initcol('sma_closes')
     >>> series.sma_closes
     [None, None, None]


    Now, we'd like to add a row for the 1997-01-04 price period:

     >>> series.append(['1997-01-04', 'goog', 38, 37])
     >>> series[3]
     ('1997-01-04', 'goog', 38, 37, None)


    As you can see, the sma_closes column is None since we didn't include it in the appended values. So, let's change that to 0.0:

     >>> series.sma_closes[3] = 0.0


    Let's format the dates column to datetime:

     >>> series.format('dates', datetime.strptime, '%Y-%m-%d')
     >>> series.dates[0].__str__()
     '1997-01-01 00:00:00'


    Finally, let's sort the series from high to low closing price:

     >>> series.sort('closes', order='d')
     >>> series.closes
     [38, 34.0, 33.0, 32.0]



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    data processing | Python library | datio library | Python | data | processing

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM