sciris.sc_legacy

Legacy methods for handling old pickles (eg Python 2 pickles). Included for backwards compatibility, but not imported into Sciris by default.

Functions

loadobj2or3

Try to load as a (Sciris-saved) Python 3 pickle; if that fails, try to load as a Python 2 pickle.

pickleMethod

unpickleMethod

Classes

legacy_dataframe

This legacy dataframe is maintained solely to allow loading old files.

loadobj2or3(filename=None, filestring=None, recursionlimit=None, **kwargs)[source]

Try to load as a (Sciris-saved) Python 3 pickle; if that fails, try to load as a Python 2 pickle. For legacy support only.

For available keyword arguments, see sc.load().

Parameters
  • filename (str) – the name of the file to load

  • filestring (str) – alternatively, specify an already-loaded bytestring

  • recursionlimit (int) – how deeply to parse objects before failing (default 1000)

class legacy_dataframe(cols=None, data=None, nrows=None)[source]

This legacy dataframe is maintained solely to allow loading old files.

Example:

import sciris as sc
from sciris import sc_legacy as scl
remapping = {'sciris.sc_dataframe.dataframe':scl.legacy_dataframe}
old = sc.load('my-old-file.obj', remapping=remapping)
Version: 2020nov29
Migrated to sc_legacy in version 2.0.0.
property ncols

Get the number of columns in the data frame

property nrows

Get the number of rows in the data frame

property shape

Equivalent to the shape of the data array, minus the headers

make(cols=None, data=None, nrows=None)[source]

Creates a dataframe from the supplied input data.

Usage examples:

df = sc.dataframe()
df = sc.dataframe(['a','b','c'])
df = sc.dataframe(['a','b','c'], nrows=2)
df = sc.dataframe([['a','b','c'],[1,2,3],[4,5,6]])
df = sc.dataframe(['a','b','c'], [[1,2,3],[4,5,6]])
df = sc.dataframe(cols=['a','b','c'], data=[[1,2,3],[4,5,6]])