BUG: loc indexing when starting with an empty frame · Issue #6252 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
from ML: https://groups.google.com/forum/#!topic/pydata/P3JFE3sob1U
empty indexing the frame
keys1 = ['@' + str(i) for i in range(1000)]
val1 = arange(1000)
keys2 = ['@' + str(i) for i in range(990)]
val2 = arange(990)
allKeys = list(set(keys1).union(keys2))
df = pandas.DataFrame(index = allKeys)
df['A'] = nan
df.loc[keys1, 'A'] = val1
df['B'] = nan
df.loc[keys2, 'B'] = val2
df.head()
## -- End pasted text --
<43>
A B
@679 679 679
@678 678 678
@337 337 337
@744 744 744
@673 673 673