• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 51 páginas
Examen

Final Exam_ Sample solutions _ Final Exam _ FA20_ Computing for Data Analysis

Document preview thumbnail
Vista previa 4 fuera de 51 páginas

At a minimum, you will need the following modules in this problem. They include a new one we did not cover called geopandas. While it may be new to you, if you have mastered pandas, then you know almost everything you need to use geopandas. Anything else you need will be given to you as part of this problem, so don't be intimidated! In [1]: * Python version: 3.7.5 (default, Dec 18 2019, 06:24:58) [GCC 5.5.0 ] * geopandas version: 0.6.2 Run the next code cell, which will load some tools needed by the test cells. In [2]: Part 1: Neighborhood ratings The neighborhood rating data is stored in a special extension of a pandas DataFrame called a GeoDataFrame. Let's load the data into a variable named neighborhood_ratings and have a peek at the first few rows: In [3]: Opening geopandas data file, './resource/asnlib/publicdata/fullD json' ... class 'taframe.GeoDataFrame' Out[3]: state city name holc_id holc_grade area_description_data ge 0 AL Birmingham Mountain Brook Estates and Country Club Garden... A1 A {'5': 'Both sales and rental prices in 1929 we... MU (((- 33. -86 1 AL Birmingham Redmont Park, Rockridge Park, Warwick Manor, a... A2 A {'5': 'Both sales and rental prices in 1929 we... MU (((- 33. -86 2 AL Birmingham Colonial Hills, Pine Crest (outside city limits) A3 A {'5': 'Generally speaking, houses are not buil... MU (((- 33. -86 3 AL Birmingham Grove Park, Hollywood, Mayfair, and Edgewood s... B1 B {'5': 'Both sales and rental prices in 1929 we... MU (((- 33. -86 4 AL Birmingham Best section of Woodlawn Highlands B10 B {'5': 'Both sales and rental prices in 1929 we... MU (((- 33. -86 Each row is a neighborhood. Its location is given by name, city, and a two-letter state abbreviation code (the name, city, and state columns, respectively). The rating assigned to a neighborhood is a letter, 'A', 'B', 'C', or 'D', given by the holc_grade column. In addition, there is special column called geometry. It contains a geographic outline of the boundaries of this neighborhood. Let's take a look at row 4 (last row shown above): In [4]: * Type of `g4_example`: class 'polygon.MultiPolygo n' * Contents of `g4_example`: MULTIPOLYGON (((-86. 33., -86.74915 6 33., -86.99999 33., -86. 33., -86. 33., -86. 33., -86.00001 33., -86. 33., -86. 33., -86. 33., -86. 3 3., -86. 33.))) * A quick visual preview: The output indicates that this boundary is stored a special object type called a MultiPolygon. It is usually a single connected polygon, but may also be the union of multiple such polygons. The coordinates of the multipolygon's corners are floating-point values, and correspond to longitude and latitude values. But for this notebook, the exact format won't be important. Simply treat the shapes as being specified in some way via a collection of two-dimensional (x, y) (x,y) coordinates measured in arbitrary units. Lastly, observe that calling display() on a MultiPolygon renders a small picture of it. Exercise 0: Filtering ratings (2 points) Complete the function, def filter_ratings(ratings, city_st, targets=None): ... so that it filters ratings data by its city and state name, along with a set of targeted letter grades. In particular, the inputs are: ratings: A geopandas GeoDataFrame similar to the neighborhood_ratings example above. city_st: The name of a city and two-letter state abbreviation as a string, e.g., city_st = 'Atlanta, GA' to request only rows for Atlanta, Georgia. targets: A Python set containing zero or more ratings, e.g., targets = {'A', 'C'} to request only rows having either an 'A' grade or a 'C' grade. The function should return a copy of the input GeoDataFrame that has the same columns as ratings but only rows that match both the desired city_st value and any one of the target ratings.


Información del documento

Subido en
14 de diciembre de 2022
Número de páginas
51
Escrito en
2022/2023
Tipo
Examen
Contiene
Preguntas y respuestas
$12.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Nechemia17
3.9
(21)
Vendido
143
Seguidores
125
Artículos
1877
Última venta
2 meses hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes

Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.