Beispiel #1
0
def make_test_listings():
    """
    Create a DataFrame with some data.
    
    Contains 3 listings: 
    row 0: contains realistic data; rows 1, 2 contain mainly None, nan.
    """
    from clair.dataframes import make_listing_frame
    
    fr = make_listing_frame(3)
    #All listings need unique ids
    fr["id"] = ["eb-123", "eb-456", "eb-457"]
    
    fr.ix[0, "training_sample"] = True 
    fr.ix[0, "search_tasks"] = ["s-nikon-d90"]
#    fr.ix[0, "query_string"] = "Nikon D90"

    fr.set_value(0, "expected_products", ["nikon-d90", "nikon-sb-24"])
    fr.ix[0, "products"] = ["nikon-d90"]
    fr.ix[0, "products_absent"] = ["nikon-sb-24"]
    
    fr.ix[0, "thumbnail"] = "www.some.site/dir/to/thumb.pg"
    fr.ix[0, "image"] = "www.some.site/dir/to/img.pg"
    fr["title"] = [u"Nikon D90 super duper!", u"<>müäh", None]
    fr.ix[0, "description"] = "Buy my old Nikon D90 camera <b>now</b>!"
    fr.set_value(0, "prod_spec", {"Marke":"Nikon", "Modell":"D90"})
    fr.ix[0, "active"] = False
    fr.ix[0, "sold"] = False
    fr.ix[0, "currency"] = "EUR"
    fr.ix[0, "price"]    = 400.
    fr.ix[0, "shipping"] = 12.
    fr.ix[0, "type"] = "auction"
    fr["time"] = [datetime(2013,1,10), datetime(2013,2,2), datetime(2013,2,3)]
    fr.ix[0, "location"] = u"Köln"
    fr.ix[0, "postcode"] = u"50667"
    fr.ix[0, "country"] = "DE"
    fr.ix[0, "condition"] = 0.7
    fr.ix[0, "server"] = "Ebay-Germany"
    fr.ix[0, "server_id"] = "123" #ID of listing on server
    fr.ix[0, "final_price"] = True
#    fr["data_directory"] = ""
    fr.ix[0, "url_webui"] = "www.some.site/dir/to/web-page.html"
#     fr.ix[0, "server_repr"] = nan
    #Put our IDs into index
    fr.set_index("id", drop=False, inplace=True, 
                 verify_integrity=True)
#    print fr
    return fr
Beispiel #2
0
def test_make_listing_frame():
    print "Start"
    from clair.dataframes import make_listing_frame
    
    lf = make_listing_frame(10)
    assert len(lf.index) == 10