mercedestrenz.data¶
Module Contents¶
Functions¶
|
Retrieves a dataframe containing sample data of used Mercedez Benz vehicles. |
|
Return the top listings that are within the budget specified by the user. |
- mercedestrenz.data.load_sample_mercedes_listings()[source]¶
Retrieves a dataframe containing sample data of used Mercedez Benz vehicles. The function returns a pandas dataframe of all sample listings.
- Returns:
A pandas dataframe of all listings contained in the package’s sample data.
- Return type:
pandas.DataFrame
Examples
>>> from mercedestrenz.data import load_sample_mercedes_listings >>> sample_mercedes_listings = load_sample_mercedes_listings()
- mercedestrenz.data.listing_search(data, budget=[0, np.Inf], model='any', sort_feature='odometer_mi', ascending=True, price_col='price_USD')[source]¶
Return the top listings that are within the budget specified by the user.
The results are filtered by an optional input, model. The results are also sorted by ascending price and another the specified feature in the sort_feature parameter. By default the sort_feature is lower mileage value, but user has the flexibility to choose another numeric attribute. Return an empty pandas dataframe when there is no listing that satisfies the criteria.
- Parameters:
data (dataframe) – The input dataframe.
budget (float or int, or list of float or int) – The maximum budget, or the range of budget when passing a list.
model (string) – The model of the car that the user is interested in. The default is to include listings of any model.
sort_feature (string) – The numeric variable that the user is interested in using to sort the result. The default value is to sort by odometer value.
ascending (bool) – Boolean value that indicate whether the sort is ascending. The default value is True.
price_col (string) – String value that indicates the column name of car price. The default is price_USD.
- Returns:
A pandas dataframe of the sorted listings that matches user’s expected budget range.
- Return type:
pandas.DataFrame
Examples
>>> # search listings within a price range >>> listing_search(data, budget=[2000, 20000], model = "any", sort_feature = "odometer_mi", ascending = True) >>> # search listings for a specific model and below a maximum price >>> listing_search(data, budget=20000, model = "gl-class", sort_feature = "odometer_mi", ascending = True)