Questions tagged [daru]

daru (Data Analysis in RUby) is a library for storage, analysis, manipulation and visualization of data in Ruby.

daru (Data Analysis in RUby) is a library for storage, analysis, manipulation and visualization of data in Ruby.

It is a standalone library maintained by the SciRuby project.

https://github.com/SciRuby/daru

17 questions
2
votes
0 answers

How to adjust the width of columns in Daru::DataFrame?

Does anyone know how to adjust the display width of columns in Daru::DataFrame ? (on terminals) https://github.com/SciRuby/daru
kojix2
  • 806
  • 7
  • 18
2
votes
1 answer

How do I address Daru Vectors in a DataFrame using symbols rather than strings?

I see this happening in a lot of online code examples, but when I parse my CSV file, all I get are strings as column indices, like > data = Daru::DataFrame.from_csv('my_fancy_data.csv') > data[:user_id] IndexError: Specified index :user_id does not…
Morpheu5
  • 2,610
  • 6
  • 39
  • 72
1
vote
0 answers

Extracting weekly or monthly data from a daily Daru time series

I am trying to understand how to obtain weekly or monthly data from a daily Daru time series. Given this sample time series: require 'daru' index = Daru::DateTimeIndex.date_range start: '2020-01-15', periods: 80, freq: 'D' data = { price:…
DannyB
  • 12,810
  • 5
  • 55
  • 65
1
vote
1 answer

How to aggregate same column multiple times in daru

I want to get grouped aggregated data, but running into a problem with the aggregating same column with multiple functions. Basically, I want to know if there is a way to rename an aggregated column, so it doesn't rewrite. Here is my code df…
janpeterka
  • 568
  • 4
  • 17
1
vote
1 answer

In Daru, how do I display multiple DataFrames in single Cell?

In daru + iruby on jupyter, how can I display multiple tables of Daru::DataFrame within a single cell?
Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
1
vote
1 answer

Daru Ruby Gem - How do I transform a categorical variable into a binary one

I have the following Daru Data Frame with a categorical variable called search_term: home,search_term,bought 0,php,1 0,java,1 1,php,1 ... I want to convert it to a Daru Data Frame with binary columns, something…
o1316043
  • 11
  • 1
1
vote
2 answers

Horizontal concat in Daru::DataFrame?

I know that by Daru::DataFrame#concat one can concatenate dataframes, appending the argument df to the bottom of the caller df. Now I want to achieve what is df.concat(other, axis=1) in Pandas. In other words, given I have two dataframes where the…
Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
0
votes
1 answer

How to flip the axis of a plot under ruby?

I wrote a ruby function to display the contents of a Daru dataframe df: def plot_dataframe(df) test = df.plot type: :line, x: :value, y: :depth test.export_html(filename='test') return end This outputs an html file named test.html. How can…
Sheldon
  • 4,084
  • 3
  • 20
  • 41
0
votes
1 answer

map each vector element to a vector

I use Daru and have a vector. vector = Daru::Vector.new({ a: 1, b: 2, c: 3}) Now, I have a function which I'd like to apply on each element and obtain result as vector. // example function; a function I'd like to apply on each element f = ->(num) {…
Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
0
votes
0 answers

Ruby, Daru, Nyaplot: Importing csv with dates into data frame

Trying to import a simple csv file with 2 columns, one date and another count. df = Daru::DataFrame.from_csv('file.csv') Now, if I try to plot: irb(main):004:0> df.plot type: :line, x: 'Date', y: 'Count' => #
0
votes
1 answer

How to get distinct count in aggregate

I simply want to get distinct_count aggregation. I have this code: data_frame = data_frame.group_by(:job_id) .aggregate(job_id: :max, bid_id: :count) I want something like this: data_frame = data_frame.group_by(:job_id) …
janpeterka
  • 568
  • 4
  • 17
0
votes
1 answer

How to reverse rows of Daru::DataFrame?

Given a Daru::DataFrame object, how do I reverse the order of rows? For example... > Daru::DataFrame.new([{a: 2, b: 2}, {a: 1, b: 3}, {a: 3, b:1}]) => # a b 0 2 2 1 1 3 2 3 1 When I have data…
Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
0
votes
1 answer

Loading a time series from CSV into a DataFrame

Is it possible to create a Daru DataFrame from a CSV in which the first column is a series of dates? Take the following CSV, for…
gioele
  • 9,748
  • 5
  • 55
  • 80
0
votes
1 answer

How can I sort by index in Daru?

In Daru, I know that by Daru::DataFrame#sort we can sort dataframe by its column, but I noticed method does not work if we want to sort dataframe by its index. Question I believe Daru::DataFrame#sort is for sorting by column. How can I sort a…
Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
0
votes
2 answers

Drop the first n rows from daru dataframe

One can drop the first n elements of an array by using Array#drop. a = [1,2,3] a.drop(2) # => [3] I want to drop the first n rows from a Daru::DataFrame object. It seems this class does not implement such drop method. How can I delete the first n…
Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
1
2