On Sun, Oct 27, 2019, at 2:48 PM, Soumaya Mauthoor wrote:
> With a dataframe you can do df.columns to get the column labels and 
> df[["col1","col2"]] to extract column1 and column2 

I'm going to guess this means that you're getting the col1/col2 from multiple 
rows at once.

In python we use a list comprehension to get this:

[(row["col1"], row["col2"]) for row in result.fetchmany()]

also the keys to each row are are present both via row.keys() as well as 
result.keys().

if you want full matrix operations available to a result set, it's best to load 
it into a pandas dataframe first, since the "fetch" is an exhaustive operation 
(e.g. only works once per row). 





> 
> rowProxy has similar functionality as explained before
> 
> However if I use s= fetchmany() I return a string and it's not possible to do 
> the equivalent s.keys() and s["col1"].
> 
> On Sun, 27 Oct 2019, 14:48 Mike Bayer, <mike...@zzzcomputing.com> wrote:
>> __
>> 
>> 
>> On Sun, Oct 27, 2019, at 7:06 AM, sumau wrote:
>>> RowProxy have useful functionality like row.keys() and row['column']
>>> 
>>> If I use fetchmany/fetchall I return a list of RowProxies. Is the best way 
>>> of keeping the functionality of RowProxies to convert the list to a pandas 
>>> data frame? Are there any plans to create "Table"Proxy equivalent to 
>>> RowProxy?
>> 
>> 
>> The "row proxy" is no longer a "proxy" in 1.4, however this is an 
>> implementation detail that won't be noticable. 
>> 
>> The table equivalent is the Table object. Just like the Row(Proxy) 
>> represents a row in a database fetched over, Table represents the structure 
>> of the Table, which can be fetched over if you use Table(..., 
>> autoload_with=connection).
>> 
>> What this has to do with a dataframe, not really sure, which suggests this 
>> is not really what you're asking, so, would use some more specifics.
>> 
>> 
>> 
>>> 
>>> -- 
>>> SQLAlchemy - 
>>> The Python SQL Toolkit and Object Relational Mapper
>>> 
>>> http://www.sqlalchemy.org/
>>> 
>>> To post example code, please provide an MCVE: Minimal, Complete, and 
>>> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
>>> description.
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "sqlalchemy" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to sqlalchemy+unsubscr...@googlegroups.com 
>>> <mailto:sqlalchemy%2bunsubscr...@googlegroups.com>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sqlalchemy/1d279f8b-f95a-49a9-b724-b12cc520c616%40googlegroups.com.
>>> 
>> 
>> 

>> --
>>  SQLAlchemy - 
>>  The Python SQL Toolkit and Object Relational Mapper
>> 
>> http://www.sqlalchemy.org/
>> 
>>  To post example code, please provide an MCVE: Minimal, Complete, and 
>> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
>> description.
>>  --- 
>>  You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>>  To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sqlalchemy+unsubscr...@googlegroups.com.
>>  To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sqlalchemy/c0ad4211-6677-4cdd-bd14-92d9899b2c30%40www.fastmail.com
>>  
>> <https://groups.google.com/d/msgid/sqlalchemy/c0ad4211-6677-4cdd-bd14-92d9899b2c30%40www.fastmail.com?utm_medium=email&utm_source=footer>.
> 

> --
>  SQLAlchemy - 
>  The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
>  To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
>  --- 
>  You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
>  To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/CAN14jWRyWKkP_gVKvt1-QxLnkkrTeBvi6mWxVtoRuFdEe9FOTg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/CAN14jWRyWKkP_gVKvt1-QxLnkkrTeBvi6mWxVtoRuFdEe9FOTg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/3f0c18a4-25b6-4f6f-acf2-d2ca580d2887%40www.fastmail.com.

Reply via email to