SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.03k stars 139 forks source link

Setting the Options. Maximum number of rows to display #502

Open kojix2 opened 5 years ago

kojix2 commented 5 years ago

Daru's data frame displays up to 30 rows. I think the default threshold of 30 is reasonable in most cases.

However, when processing messy data, I often want to see 100 lines or more with my own eyes.

The threshold is defined as default values ​​for the arguments here.

https://github.com/SciRuby/daru/blob/d17887e279c27e2b2ec7a252627c04b4b03c0a7a/lib/daru/dataframe.rb#L2094

So, you can change the threshold with the following patch.

class Daru::DataFrame
    alias_method :__to_html__, :to_html
    def to_html
        __to_html__(100)
    end
end

This is not a cool way. I want a better way to configure Daru.

Shekharrajak commented 5 years ago

Yes! It makes sense. There was a similar discussion happened https://github.com/SciRuby/daru/pull/476 , please have a look.

kojix2 commented 5 years ago

My first idea is like

Daru.configure do |c|
  c.max_rows = 100
  c.max_columns = nil
end

But I think this is good too.

Daru::DataFrame.inspect_max_rows = 10
Daru::DataFrame.inspect_max_colms = nil
Daru::Vector.inspect_max_rows = nil 
Shekharrajak commented 5 years ago

Thanks for letting me this. Yes! We can have configuration as well, where all these default things can be set.

kojix2 commented 5 years ago

I realized that setting options alone was not enough for me. I want to display a particular data frame / vector only once. For such use, a method like show_all may be more appropriate than config.

df.show_all

Shekharrajak commented 5 years ago

Thanks for suggestion @kojix2 .

I think we should have global option to set the maximum number of rows to display as well as all_rows and all_colms property in dataframe level.

WDYT?