Sha256: c5f086d57370ce4937a660421b4beebbaebddaa1203ff0b31492d70e7987ebea
Contents?: true
Size: 772 Bytes
Versions: 15
Compression:
Stored size: 772 Bytes
Contents
module RbbtPython def self.py2ruby_a(array) PyCall::List.(array).to_a end class << self alias to_a py2ruby_a end def self.tsv2df(tsv) df = nil RbbtPython.run 'pandas' do df = pandas.DataFrame.new(tsv.values, columns: tsv.fields, index: tsv.keys) df.columns.name = tsv.key_field end df end def self.df2tsv(tuple, options = {}) options = Misc.add_defaults options, :type => :list IndiferentHash.setup options tsv = TSV.setup({}, options) tsv.key_field = options[:key_field] || tuple.columns.name tsv.fields = py2ruby_a(tuple.columns.values) keys = tuple.index.values PyCall.len(tuple.index).times do |i| k = keys[i] tsv[k] = py2ruby_a(tuple.values[i]) end tsv end end
Version data entries
15 entries across 15 versions & 1 rubygems