ns am brand-new to Python and also I to be facing difficulty in developing the Dataframe in the style of key and worth i.e.

You are watching: Valueerror: dataframe constructor not properly called!

data = <"key":"","value":"1000",>Here is mine code:

columnsss = <"key","value">;query = "select * native bparst_tags wherein tag_type = 1 ";result = database.cursor(db.cursors.DictCursor);result.execute(query);result_set = result.fetchall();data = "<";for heat in result_set:`row<"tag_expression">`) data += ""value": %s , "key": %s ," % ( `row<"tag_expression">`, `row<"tag_name">` )data += ">" ; df = DataFrame(data , columns=columnsss); however when i pass the data in DataFrame it reflects me

pandas.core.common.PandasError: DataFrame constructor not effectively called!

while if I print the data and assign the exact same value to data variable climate it works.

python pandas
improve this inquiry
edited Mar 31 in ~ 11:36

17.1k99 gold badges2525 silver- badges4444 bronze badges
asked Sep 1 "14 in ~ 10:47

Ravi khatriRavi khatri
42511 gold badge55 silver badges1111 bronze title
include a comment |

2 answers 2

active oldest Votes
You are giving a string depiction of a dict come the DataFrame constructor, and also not a dict itself. For this reason this is the reason you acquire that error.

So if you want to use your code, you can do:

df = DataFrame(eval(data))But far better would it is in to not produce the wire in the first place, but directly placing it in a dict. Something around like:

data = <>for row in result_set: data.append("value": row<"tag_expression">, "key": row<"tag_name">)But probably even this is no needed, as depending upon what is precisely in your result_set you could probably:

provide this directly to a DataFrame: DataFrame(result_set)
boost this prize
edited Sep 1 "14 at 11:31
reply Sep 1 "14 in ~ 11:24

113k3333 yellow badges228228 silver- badges192192 bronze title
add a comment |
Just ran right into the same error, yet the above answer can not help me.

My code functioned fine ~ above my computer which was prefer this:

test_dict = "x": "123", "y": "456", "z": "456"df=pd.DataFrame(test_dict.items(),columns=<"col1","col2">)However, that did not work on one more platform. It provided me the same error as discussed in the original question. I tried listed below code by simply adding the list() approximately the dictionary items, and it worked smoothly after:

df=pd.DataFrame(list(test_dict.items()),columns=<"col1","col2">)Hopefully, this price can aid whoever ran into a comparable situation favor me.

enhance this price
reply Mar 29 at 17:00

6522 silver badges99 bronze badges
add a comment |

her Answer

Thanks because that contributing an answer to stack Overflow!

Please be sure to answer the question. Provide details and also share your research!

But avoid

Asking because that help, clarification, or responding to various other answers.Making statements based upon opinion; ago them increase with references or personal experience.

To discover more, see our tips on writing good answers.

See more: ' Tiara From Love And Hip Hop Atlanta Pregnant? Fans Are Confused Af

Draft saved
Draft discarded

Sign increase or log in in

authorize up making use of Google
sign up making use of Facebook
sign up making use of Email and Password

Post as a guest

email Required, but never shown

Post together a guest


Required, but never shown

post Your answer Discard

By click “Post her Answer”, friend agree come our regards to service, privacy policy and cookie policy

Not the prize you're looking for? Browse various other questions tagged python pandas or asking your own question.

The Overflow Blog
Featured ~ above Meta
Getting Error while trying develop a spark dataframe in pandas
Pandas just how to append data in the exact same DataFrame using a for loop?
picking multiple columns in a Pandas dataframe
exactly how to adjust the order of DataFrame columns?
Delete a column from a Pandas DataFrame
"Large data" workflows making use of pandas
how do I get the heat count of a Pandas DataFrame?
just how to iterate over rows in a DataFrame in Pandas
exactly how do I select rows from a DataFrame based upon column values?
transform Python dict right into a dataframe
gain a perform from Pandas DataFrame column headers
How can I pivot a dataframe?
hot Network inquiries more hot inquiries

concern feed
subscribe to RSS
inquiry feed To subscribe to this RSS feed, copy and also paste this URL into your RSS reader.


ridge Overflow
ridge Exchange Network
site architecture / logo design © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.10.29.40598

Stack Overflow works finest with JavaScript enabled

your privacy

By clicking “Accept every cookies”, friend agree stack Exchange have the right to store cookies on your maker and disclose information in accordance v our Cookie Policy.