Q1: Write 2 python function to get the indices of the sorted elements of given lists and compare the speed. one is without numpy package and the other is with numpy. (raise a error message if the input is null or not numerical)
- List 1: [23, 104, 5, 190, 8, 7, -3]
- List 2 : []
- List 3 : random generate 1000000 integers
The output for exercise Q1 is (output for list3 is commented out):
Sorted indices without NumPy for list 1: [6, 2, 5, 4, 0, 1, 3]
Time taken without NumPy for list1: 0.000997304916381836 seconds
Sorted indices with NumPy for list 1: [6 2 5 4 0 1 3]
Time taken with NumPy for list1: 0.0 seconds
Input list is empty
Input list is empty
Time taken without NumPy for list3: 1.224100112915039 seconds
Time taken with NumPy for list3: 0.402069091796875 seconds
Time taken without NumPy for list1: 0.000997304916381836 seconds
Sorted indices with NumPy for list 1: [6 2 5 4 0 1 3]
Time taken with NumPy for list1: 0.0 seconds
Input list is empty
Input list is empty
Time taken without NumPy for list3: 1.224100112915039 seconds
Time taken with NumPy for list3: 0.402069091796875 seconds
As we aspected the output time with NumPy is much shorter.
- Load the countries.csv directly via URL import into your panda data frame!
- Display descriptive statistics for the numerical column (count, mean, std, min, 25%, 50%, 75%, max) HINT: describe
- Show the last 4 rows of the data frame.
- Show all the rows of countries that have the EURO
- Show only name and Currency in a new data frame
- Show only the rows/countries that have more than 2000 GDP (it is in Milliarden USD Bruttoinlandsprodukt)
- Select all countries where with inhabitants between 50 and 150 Mio
- Calculate the GDP average (ignore the missing value)
- Calculate the GDP average (missing value treated as 0)
- Calculate the population density (population/area) of all countries and add as new column
- Sort by country name alphabetically
- Create a new data frame from the original where the area is changed: all countries with > 1000000 get BIG and <= 1000000 get SMALL in the cell replaced!