GithubHelp home page GithubHelp logo

isabella232 / palantir-python-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from palantir/palantir-python-sdk

0.0 0.0 0.0 88 KB

Palantir Python SDK

License: Apache License 2.0

Python 100.00%

palantir-python-sdk's Introduction

Palantir Python SDK

PyPI - Python Version PyPI License Autorelease

This SDK is incubating and subject to change.

Setup

pip install palantir-sdk
conda config --add channels conda-forge  # add conda-forge channel if not already enabled
conda install palantir-sdk
mamba install palantir-sdk  # alternatively install with mamba

Configuration for hostname and an authentication token are provided by environment variables (PALANTIR_HOSTNAME, PALANTIR_TOKEN)

  • PALANTIR_HOSTNAME is the hostname of your instance e.g. example.palantirfoundry.com
  • PALANTIR_TOKEN is a token acquired from the Tokens section of Foundry Settings

Authentication tokens serve as a private password and allows a connection to Foundry data. Keep your token secret and do not share it with anyone else. Do not add a token to a source controlled or shared file.

Examples

Read a Foundry Dataset into a Pandas DataFrame

from palantir.datasets import dataset

dataset("/Path/to/dataset") \
    .read_pandas()
            id        word  length     double boolean
0            0           A     1.0  11.878200       1
1            1           a     1.0  11.578800       0
2            2          aa     2.0  15.738500       1
3            3         aal     3.0   6.643900       0
4            4       aalii     5.0   2.017730       1
...        ...         ...     ...        ...     ...
235881  235881      zythem     6.0  19.427400       1
235882  235882      Zythia     6.0  14.397100       1
235883  235883      zythum     6.0   3.385820       0
235884  235884     Zyzomys     7.0   6.208830       1
235885  235885  Zyzzogeton    10.0   0.947821       0

[235886 rows x 5 columns]

Write a Pandas DataFrame to a Foundry Dataset

import pandas as pd
from palantir.datasets import dataset

df = pd.DataFrame({
    "string": ["one", "two"],
    "integer": [1, 2]
})

ds = dataset(f"/Path/to/dataset", create=True)
ds.write_pandas(df)

List files in a Dataset

from palantir.datasets import dataset

files = dataset("/Path/to/dataset") \
    .list_files() # returns a generator over pages of files

list(files)
[
    File("ri.foundry.main.dataset.2ed83c69-e87e-425e-9a1c-03b77b5b0831", "file.txt")
]

Read the contents of a file from a dataset (by name)

from palantir.datasets import dataset

dataset("/Path/to/dataset") \
    .file("file.txt") \
    .read()
b'Hello!'

Read the contents of a file from a dataset (by exploration / listing)

from palantir.datasets import dataset

files = dataset("/Path/to/dataset").list_files()
next(files).read()
b'Hello!'

Dataset functions also accept Resource Identifiers (rids)

from palantir.datasets import dataset

dataset("ri.foundry.main.dataset.a0a94f00-754e-49ff-a4f6-4f5cc200d45d") \
    .read_pandas()
  string  integer
0    one        1
1    two        2

Contributing

See the CONTRIBUTING.md document. Releases are published to pypi on tag builds and are automatically re-published to conda using conda-forge.

License

This project is made available under the Apache 2.0 License.

palantir-python-sdk's People

Contributors

ahggns avatar alexandreguinaudeau avatar askyel avatar ktekelioglu avatar svc-autorelease avatar svc-excavator-bot avatar

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.