Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-07 Thread Luca
On 4/6/2020 11:05 PM, Luca wrote: On 4/6/2020 8:51 PM, Reto wrote: out = df.to_csv(None) new = pd.read_csv(io.StringIO(out), index_col=0) Thank you, brother. It works BTW, a little gotcha (I write this in case someone gets here in the future through Google or something) """ import pandas

Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Luca
On 4/6/2020 8:51 PM, Reto wrote: out = df.to_csv(None) new = pd.read_csv(io.StringIO(out), index_col=0) Thank you, brother. It works -- https://mail.python.org/mailman/listinfo/python-list

Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Reto
On Mon, Apr 06, 2020 at 06:29:01PM -0400, Luca wrote: > so, given a dataframe, how do I make it print itself out as CSV? read the docs of to_csv... > And given CSV data in my clipboard, how do I paste it into a Jupiter cell > (possibly along with a line or two of code) that will create a datafram

Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Luca
On 4/6/2020 3:03 PM, Christian Gollwitzer wrote: CSV is the most sensible option here. It is widely supported by spreadsheets etc. and easily copy/pasteable. Thank you Christian. so, given a dataframe, how do I make it print itself out as CSV? And given CSV data in my clipboard, how do I

Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Christian Gollwitzer
Am 06.04.20 um 17:17 schrieb Luca: On 4/6/2020 4:08 AM, Reto wrote: Does this help? Thank you, but not really. What I am trying to achieve is to have a way to copy and paste small yet complete dataframes (which may be the result of previous calculations) between a document (TXT, Word, Google

Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Luca
On 4/6/2020 4:08 AM, Reto wrote: Does this help? Thank you, but not really. What I am trying to achieve is to have a way to copy and paste small yet complete dataframes (which may be the result of previous calculations) between a document (TXT, Word, GoogleDoc) and Jupiter/IPython. Did I m

Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Reto
On Sat, Apr 04, 2020 at 07:00:23PM -0400, Luca wrote: > dframe.to_string > > gives: > > 0 a0 b0 c0 d0 > 1 a1 b1 c1 d1 > 2 a2 b2 c2 d2 > 3 a3 b3 c3 d3> That's not the output of to_string. to_string is a method, not an attribute which is apparent by the > comment in your output

print small DataFrame to STDOUT and read it back into dataframe

2020-04-04 Thread Luca
possibly a stupid question. Let's say I have a (small) dataframe: import pandas as pd dframe = pd.DataFrame({'A': ['a0','a1','a2','a3'], 'B': ['b0','b1','b2','b3'], 'C': ['c0','c1','c2','c3'], 'D': ['d0','d1','d2','d3']}, i