Esempio n. 1
0
def create_matrix_nan():
    """Create nullity matrix and save the plot to ``matrix_nan.png``
    in the "OUT_DATA" directory.

    """
    index_missing = gate_plot.isna().sum().sort_values().index
    sorted_by_missing = msno.nullity_sort(gate_plot[index_missing])
    matrix_nan = msno.matrix(sorted_by_missing)
    matrix_nan.set_ylabel("INDEX OF OBSERVATIONS", labelpad=0, fontsize=18)
    matrix_nan.get_xticklabels()[19].set_fontweight("bold")
    matrix_nan.figure.savefig(ppj("OUT_FIGURES", "matrix_nan.png"),
                              bbox_inches="tight")
Esempio n. 2
0
)
plt.show()
data = data.loc[~data.variable.str.contains('exploitable'), :]
#Deep dive:National rainfall index
msno.matrix(variable_slice(data, 'national_rainfall_index'),
            inline=False,
            sort='descending')
plt.xlabel('Time period')
plt.ylabel('Country')
plt.title(
    'Missing national rainfall index data across countries and time periods \n \n \n \n'
)
data = data.loc[~(data.variable == 'national_rainfall_index')]
#By country
north_america = subregion(data, 'North America')
msno.matrix(msno.nullity_sort(time_slice(north_america, '2013-2017'),
                              sort='descending').T,
            inline=False)
plt.show()
msno.nullity_filter(country_slice(data, 'Bahamas').T, filter='bottom', p=0.1)
#By country for a single variable
geo = r'world.json'

null_data = recent['agg_to_gdp'].notnull() * 1
map = folium.Map(location=[48, -102], zoom_start=2)
map.choropleth(
    geo_data=geo,
    data=null_data,
    columns=['country', 'agg_to_gdp'],
    key_on='feature.properties.name',
    reset=True,
    fill_color='GnBu',
Esempio n. 3
0
 def test_descending_sort(self):
     result = msno.nullity_sort(self.df, sort='descending')
     expected = self.df.iloc[[0, 1, 2]]
     assert result.equals(expected)
Esempio n. 4
0
    def test_no_op(self):
        expected = self.df
        result = msno.nullity_sort(self.df, sort=None)

        assert result.equals(expected)