Issue 1:
This code all "works," but in a surprising way:

import pandas as pd
t0 = 1234567890123400000
df1 = pd.DataFrame(index=pd.DatetimeIndex([t0, t0 + 1000, t0 + 2000, t0 + 3000]))
df2 = pd.DataFrame(index=range(4))
df1.loc[:2, 'a'] = np.arange(2)
df2.loc[:2, 'a'] = np.arange(3)

We create df1 with a DatetimeIndex and df2 with an integer index. We then create a new column a in each, using .loc[] with an integer slice. With df1 we get the intuitive, normal Python slice behavior where [:2] means "the first 2 elements", whereas with df2 we get the bizarre—but documented—DataFrame.loc slice behavior where [:2] means "elements up to index 2, inclusive."

I don't see why the type of index the DataFrame has should affect the semantics of slicing with .loc[]. I happen to think the exclusive-end behavior is correct in all cases, though apparently Pandas has decided (or at least documented) that .loc[] slicing is inclusive (in which case the DatetimeIndex case looks like a bug).

Also note that trying to "read" df1.loc[:2, 'a'] (e.g. to print it) fails, saying:

TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'>
with these indexers [2] of <class 'int'>

It's sort of strange that you can assign to this slice but not read from it.

I'm using Pandas 0.18.1.

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

import glob
import pandas as pd

files = glob.glob('*.tab')

dfs = [pd.read_csv(fp, sep='\t',index_col=[0], header=0) for fp in files]

df = pd.merge(dfs[0], dfs[1],how='outer', left_index=True, right_index=True).sort_index()

df1 = pd.merge(dfs[2], df, how='outer', left_index=True, right_index=True).sort_index()

df2 = df1.fillna('-')

df3 = df2.drop_duplicates(keep='first') #Not working properly

print (df3)

df3.to_csv('/home/jsena/Documents/atten_sites_1.csv', sep='\t')

Problem description

I used the code above to combine and merage several tab separated files. I then attempted to remove duplicate rows with drop_duplicates. When I use drop_duplicates, unique rows are being removed. However, If I use command-line tools I can get the correct output.

Thank you very much for your help!

Input Files:

5270.txt

2579.txt

57.txt

note: I had to change the extension from .tab to .txt to attach the files.

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.

Upgrading Pandas did not solve my issue. I get the same results with conda and pandas

Pandas version used with conda

pd.version

'0.22.0'

Expected Output

expected_output.txt

read	56	2578	5269

100005/ccs#CACTAGTCTGTTATTC	T	A	T

100009/ccs#CCACAATGGCGGCACT	T	A	T

100013/ccs#CACCTCCACCGTTAAT	T	A	T

00017/ccs#CCTTCACAGTATAACA	T	-	T

100021/ccs#ACCTTGAATCGTCGAC	T	A	T

100023/ccs#CCGACTGTCATATGGT	T	A	T

100027/ccs#CCGCATTCCGAAATTA	T	A	T

10004/ccs#CTCTTGCACAAAATCG	T	A	T

drop_duplicates output

pandas_output.txt

read	56	2578	5269

100005/ccs#CACTAGTCTGTTATTC	T	A	T

100017/ccs#CCTTCACAGTATAACA	T	-	T

100075/ccs#CTCTGTAAGTGTCCTT	-	A	T

10008/ccs#CCAGCTTCGGACCAGC	T	A	-

10052/ccs#CCCATCCGGTCGAAAC	-	-	T

100575/ccs#CGGTACTTGTGTTTTC	-	A	-

100734/ccs#CCGCACTCCTGCTCAC	T	-	-

101808/ccs#CATGCGATCGAAACCG	C	A	T

Output of pd.show_versions()

Python and Pandas version

Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)

[GCC 7.2.0] on linux

pandas.version

'0.20.3'