What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

This question already has an answer here:

Probably a noob question. When I post a question, It is easier for the viewers to have some simplistic data to understand the problem. Creating the data with the sample code is only feasible if it is relatively small. With more complex questions the data needed is not easily entered as code.

E.g. When asking question on a pandas dataframe, the code needed to get some illustrative data for a complex operation is very long.

Is there a way to elegantly link the data to the question?

share|improve this question

migrated from stackoverflow.com Jun 10 '13 at 10:02

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Shadow Wizard, Time Traveling Bobby, hims056, Lucifer, Rory Jun 10 '13 at 12:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 2 down vote accepted

I've answered quite a few questions, so I think I'm qualified to say that you really don't need to. There will be a sample DataFrame and a few lines (more than a dozen and I'd be concerned) of offending code to recreate a not-working example. Extracting those so is a key exercise to understanding (and solving!) problems.

An example, from your earlier (motivating?) question:

Your code fragment (basically you said "this isn't working in 0.11"):

accurate_list = ['corr1', 'corr2', 'corr3']
x = df[~df.Classification.isin(accurate_list)]
df.ix[x.index,'A'] = df['Classification']  # you say it bugged out here

You didn't give an example, so I created a random DataFrame (actually I just had this one lying around already) which I thought may give me an example of the exception:

df = pd.DataFrame([[1,10,20,30], [1,40,50,60], [2,20,30,40],], columns=list('ABCD'))

x = df[~(df.A.isin([2]))]
df.ix[x.index, 'A'] = df['D']  # worked fine, no exception

I couldn't replicate it, so I posted as such as a comment.

I guess I was really asking is:

"What is different about your DataFrame to mine"?

I suspect that if you can answer that, you'll be able to come up with a better example which you can fit in a few lines... in doing so you may even find the answer to your question. :)

But what we don't want is you linking to an external (Gb?) file... Please don't do that!

share|improve this answer
    
Thanks... you are right. Problem is that I cannot seem to recreate the problem with a small dataframe... also made a typo (since corrected), error is not exception, the wrong data is copied to the column. Still trying various arrangements of data to see when it happens. My original dataframe is 175 rows by 44 columns. None of the smaller samples seem to recreate the error though. Wrong place for further discussion on my other question though –  Joop Jun 10 '13 at 12:32
    
I agree with hayden on keeping examples small. StringIO is a nice way for faking files in case the problem can only be replicated with functions like pd.read_csv(). If you really need to, hosting it somewhere allows you to create an example like: df = pd.read_csv(urllib2.urlopen('http://somedomain.pd/example.csv')) With the risk of dead links in the future, so definitely not recommended. –  Rutger Kassies Jun 10 '13 at 14:02
1  
@RutgerKassies I favour just printing the DataFrame and then we can use pd.read_clipboard, so we both refer to it as read_csv (since it's really just a wrapper). –  hayd Jun 10 '13 at 14:32

Not the answer you're looking for? Browse other questions tagged .