Issue 1:
Code Sample, a copy-pastable example if possible

# categorical_DataFrame is constructed from a source table by appending transformed original data column-by-column using original_DataFrame[column_name].values
# The original dataframe has also undergone some operations after loading and before constructing the categorical_DataFrame: type conversion, value substitution, and re-indexing.
categorical_DataFrame = pd.DataFrame(index=origin_DataFrame['GID'])
for akey, avalue in column_translation_dict.items():
if akey in origin_DataFrame.columns:
categorical_DataFrame[avalue] = origin_DataFrame[akey].values
else:
print('Cannot find column ' + akey)

# trying to visualize
for column_name in categorical_DataFrame:
if str(categorical_DataFrame[column_name].dtype) is 'category':
count_Series = categorical_DataFrame[column_name].value_counts(dropna=False) # Same bug if dropna=True
print(count_Series) # This yields the correct result
plt_ax = count_Series.plot.bar() # This yields incorrect graph

# If save it to a new .csv file and reload, though:
categorical_DataFrame.to_csv('saved_table.csv')
new_DataFrame = pd.read_csv('saved_table.csv', index_cols='GID')
for column_name in new_DataFrame:
if str(new_DataFrame[column_name].dtype) is 'category':
count_Series = new_DataFrame[column_name].value_counts(dropna=False) # basically same operations
print(count_Series) # Still correct
plt_ax = count_Series.plot.bar() # This now yields correct graphs.

Problem description

Most of the details have been commented in the code.

In addition to that, the graphs are wrong in several aspects:

The original table contains many values '-77' or '-77.0', which I substituted with np.nan and confirmed in the printout of Series.value_counts for each column; however, the plots still show none-zero counts of "-77".

The counts of other values also contain mistakes (not all, but some).

The 'GID' index column contains nan and duplicates, but that does not seem to affect value_counts() function as the sum of all groups' counts (including nan) always equals the total number of rows.

Versions used:

pandas: both 0.20.3 and newest version (v0.22.0)

matplotlib: both 2.0.2 and 2.2.0, with and without explicit importing. (but I don't think it would affect pandas plotting)

[this should explain why the current behaviour is a problem and why the expected output is a better solution.]

Note: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!

Note: Many problems can be resolved by simply upgrading pandas to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check if master addresses this issue, but that is not necessary.

For documentation-related issues, you can check the latest versions of the docs on master here:

https://pandas-docs.github.io/pandas-docs-travis/

If the issue has not been resolved there, go ahead and file it in the issue tracker.

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None

python: 3.6.1.final.0

python-bits: 64

OS: Windows

OS-release: 10

machine: AMD64

processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel

byteorder: little

LC_ALL: None

LANG: en

LOCALE: None.None

pandas: 0.22.0

pytest: 3.0.7

pip: 9.0.1

setuptools: 27.2.0

Cython: 0.25.2

numpy: 1.12.1

scipy: 0.19.0

pyarrow: None

xarray: None

IPython: 5.3.0

sphinx: 1.5.6

patsy: 0.4.1

dateutil: 2.6.0

pytz: 2017.2

blosc: None

bottleneck: 1.2.1

tables: 3.4.2

numexpr: 2.6.2

feather: None

matplotlib: 2.2.0

openpyxl: 2.4.7

xlrd: 1.0.0

xlwt: 1.2.0

xlsxwriter: 0.9.6

lxml: 3.7.3

bs4: 4.6.0

html5lib: 0.9999999

sqlalchemy: 1.1.9

pymysql: None

psycopg2: None

jinja2: 2.9.6

s3fs: None

fastparquet: None

pandas_gbq: None

pandas_datareader: None

Issue 2:
Code Sample

>>> pd.DataFrame().drop_duplicates()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/analytical-monk/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py", line 3098, in drop_duplicates
duplicated = self.duplicated(subset, keep=keep)
File "/home/analytical-monk/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py", line 3144, in duplicated
labels, shape = map(list, zip(*map(f, vals)))
ValueError: not enough values to unpack (expected 2, got 0)

Problem description

Currently, calling the drop_duplicates method for an empty dataframe object (simply pd.DataFrame()) throws an error.

Ideally it should return back the empty dataframe just liked it does when at least one column is present.

Expected Output

>>> pd.DataFrame().drop_duplicates()

Empty DataFrame
Columns: []
Index: []

Output of pd.show_versions()

>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.8.0-58-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_IN
LOCALE: en_IN.ISO8859-1

pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.6.0
Cython: None
numpy: 1.13.1
scipy: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 1.0b10
sqlalchemy: 1.1.14
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None