Code Monkey home page Code Monkey logo

dsxtools's Introduction

dsxtools

Tools built to help work with Python notebooks in Data Science Experience

Installation

In a Python 3 DSX notebook:

!pip install git+https://github.com/gfilla/dsxtools.git

Hope to support Python 2 and get into Pypi in the future!

Basic Usage

Inside a DSX Notebook, insert your credentials to the notebook using insert to code. The variable name for the credentials will be used for the methods in this package.

creds = {
 'auth_url':'https://identity.open.softlayer.com',
 'project':
 'project_id':
 'region':'dallas',
 'user_id':
 'domain_id':
 'domain_name':
 'username':
 'password':
 'container':
 'tenantId':'undefined',
 'filename':
}

Using Object Storage with dsxtools

Getting Data

from dsxtools import objectStore

my_os = objectStore(creds)
df = my_os.get_csv(NAME OF FILE IN YOUR CONTAINER)

That is how you get a CSV file. The file is returned as a Pandas dataframe. If you are reading in a text file or just want a string of the file contents, use get_string() instead of get_csv

Putting Data in Object Store

my_os.put_csv(fileName= path+fname, fname= 'testing.csv')

Accepts a fileName which is the location of the CSV file stored locally. In DSX, you accomplish this by using something like to_csv() from Pandas on a dataframe. fname in this function is the desired name of the file when it is put in the Object Storage container.

Listing Files in the Container

This is a helpful function when working with repositories of data or many CSVs that you need to iterate through for processing. Returns a list of files in the container that was specified when the credentials were passed to create an instance of the objectStore class.

my_os.list_files()

Using Python modules stored in Object Storage

A typical workflow in DSX is to build a large module as a Python script and import it for use in a notebok. To help with this, use import_python for Python scripts in your Object Storage container. This function saves the Python script in the working directory so you can import it in your notebook. Prints a confirmation that the module was saved in the notebook environment. Usage:

my_os.import_python(fileName = 'myModule.py')

dsxtools's People

Contributors

gfilla avatar

Watchers

 avatar

Forkers

oleggorj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.