0

The output table of the code below isn't sorted although I included the sorting in the code. Please see the warning message

I have the same code running for a different dataset and works fine. Basically I want to see all the columns that have missing values sorted by ascending values; so I can easily see the columns that have more missing values at the top.

import pandas as pd
import numpy as np

location = "DC_Properties.csv"
dc_df = pd.read_csv(location)
dc_df.head(7) #print 7 first rows

total = dc_df.isnull().sum().sort_values(ascending=False)
percent_1 = dc_df.isnull().sum()/dc_df.isnull().count()*100
percent_2 = (round(percent_1, 1)).sort_values(ascending=False)
missing_data = pd.concat([total, percent_2], axis=1, keys=['Total', '%'])
missing_data.head(20)`

C:\Users\nikil\Anaconda3\lib\site-packages\ipykernel_launcher.py:5: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version of pandas will change to not sort by default. To accept the future behavior, pass 'sort=False'. To retain the current behavior and silence the warning, pass 'sort=True'.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Nikillo
  • 11
  • 3
  • Just do what the warning says, pass `sort=False` or `sort=True` to `concat`. – Trenton McKinney Oct 19 '19 at 17:04
  • Possible duplicate of [Python Pandas User Warning: Sorting because non-concatenation axis is not aligned](https://stackoverflow.com/questions/50501787/python-pandas-user-warning-sorting-because-non-concatenation-axis-is-not-aligne) – Trenton McKinney Oct 19 '19 at 17:05

0 Answers0