SciRuby / daru

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

save converted dataframe to particular html file #322

Closed Shekharrajak closed 7 years ago

Shekharrajak commented 7 years ago

User must be able to pass "path of html file" to store converted df.

E.g.

df.to_html(file: 'html_file_path.html')

the output of df.to_html will be saved in html_file_path.html.

Shekharrajak commented 7 years ago

Also the output of to_html is not understandable in iruby notebook. It comes something like this

"<table>\n  <tr>\n    <th colspan='4'>Daru::DataFrame(5x3)</th>\n  </tr>\n\n  \n    <tr>\n      <th></th>\n      \n        <th>a</th>\n      \n        <th>b</th>\n      \n        <th>c</th>\n      \n    </tr>\n  \n\n  \n    <tr>\n      <td>one</td>\n      \n        <td>1</td>\n      \n        <td>11</td>\n      \n        <td>11</td>\n      \n    </tr>\n  \n\n  \n    <tr>\n      \n        <td>...</td>\n      \n        <td>...</td>\n      \n        <td>...</td>\n      \n        <td>...</td>\n      \n    </tr>\n\n    \n\n    <tr>\n      <td>five</td>\n        \n          <td>5</td>\n        \n          <td>15</td>\n        \n          <td>55</td>\n        \n    </tr>\n  \n</table>"
zverok commented 7 years ago

User must be able to pass "path of html file" to store converted df.

What is the (frequent) use case? How this is better than File.write 'something.html', df.to_html?

Also the output of to_html is not understandable in iruby notebook. It comes something like this

What do you mean by "not understandable"? What have you expected and how actual output is different from your expectactions?

gnilrets commented 7 years ago

I agree with @zverok, there's no need to have this functionality in Daru, as any user can easily write it to a file themselves.

@Shekharrajak - I think I know what you're talking about with it not being understandable in iRuby. If you want to use to_html in an iRuby notebook, use IRuby.display and specify the mime type. I often do this when I want to see more than the default number of records:

IRuby.display df.to_html(100), mime: 'text/html'
Shekharrajak commented 7 years ago

What is the (frequent) use case? How this is better than File.write 'something.html', df.to_html?

@zverok Yes , we can do this. There is not much use case right now.

What do you mean by "not understandable"? What have you expected and how actual output is different from your expectactions?

In IRuby or using terminal, we get output with html tags, which is not readable.

screen shot 2017-03-16 at 10 17 59 pm

If we see this in Pandas then output is more readable :

screen shot 2017-03-16 at 10 15 24 pm

If you want to use to_html in an iRuby notebook, use IRuby.display and specify the mime type. I often do this when I want to see more than the default number of records:

@gnilrets , Thanks for sharing it

zverok commented 7 years ago

In IRuby or using terminal, we get output with html tags, which is not readable.

For default output (like in pandas), just don't do to_html, it returns exactly "raw HTML string" output, as you can see. If you'll just do

> dataframe

-- you'll see pretty HTML output. And if you'll do

> dataframe.method(:to_html)

...you'll see

 => #<Method: Daru::DataFrame#to_html> 

(That is what df.to_html does in pandas, returning method object instead of calling it)

Shekharrajak commented 7 years ago

Thanks @zverok .