0

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'
=> #<Nyaplot::Plot:0x0000000004234818 @properties={
  :diagrams => [
    #<Nyaplot::Diagram:0x00000000041eace0
      @properties = {
        :type => :line,
        :options => { :x => "Date", :y => "Count" },
        :data => "bde6ab93-4ef6-4d03-b9fd-bf2681d41f56"
      },
      @xrange = [ "6/1/2020", "6/9/2020" ],
      @yrange = [ 100, 228 ]>
    ],
    :options => {}
 }>

The dates are actually from 6/1/2020 to 6/30/2020. The y range is showing correctly.

Is Daru not recognizing dates correctly?

Rystraum
  • 1,985
  • 1
  • 20
  • 32
  • 1
    Hi, welcome to Stack Overflow! I'm not familiar with Daru, but I'm guessing that it's probably the date format. 6/1/2020 is being read as January 6, 2020 and not June 1, 2020. 6/30/2020 is being read as an invalid date, and that's probably why you're getting unexpected results. Just a hunch. – Rystraum Jul 01 '20 at 16:09
  • @Rystraum When I use R, I am able to overcome this problem with as.Date() function. But unable to figure out how to work around this difficulty in Daru. – Umamaheshwar Jul 12 '20 at 13:40
  • 1
    Can you try using 2020-06-01 and 2020-06-09 instead? Or you can convert them to Ruby dates: `Date.new(2020, 6, 1)` – Rystraum Jul 13 '20 at 15:09

0 Answers0