@@ -5,11 +5,6 @@ v0.14.0 (May 31 , 2014)
5
5
6
6
{{ header }}
7
7
8
- .. ipython :: python
9
- :suppress:
10
-
11
-
12
-
13
8
This is a major release from 0.13.1 and includes a small number of API changes, several new features,
14
9
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
15
10
users upgrade to this version.
@@ -63,8 +58,9 @@ API changes
63
58
64
59
.. ipython :: python
65
60
66
- import pandas.DataFrame as DataFrame
67
- dfl = DataFrame(np.random.randn(5 , 2 ), columns = list (' AB' ))
61
+ import pandas as pd
62
+
63
+ dfl = pd.DataFrame(np.random.randn(5 , 2 ), columns = list (' AB' ))
68
64
dfl
69
65
dfl.iloc[:, 2 :3 ]
70
66
dfl.iloc[:, 1 :3 ]
@@ -138,13 +134,11 @@ API changes
138
134
.. ipython :: python
139
135
:suppress:
140
136
141
- import pandas.MultiIndex as MultiIndex
142
- import pandas.Series as Series
143
137
np.random.seed(1234 )
144
138
from itertools import product
145
139
tuples = list (product((' a' , ' b' ), (' c' , ' d' )))
146
- mi = MultiIndex.from_tuples(tuples)
147
- df_multi = DataFrame(np.random.randn(4 , 2 ), index = mi)
140
+ mi = pd. MultiIndex.from_tuples(tuples)
141
+ df_multi = pd. DataFrame(np.random.randn(4 , 2 ), index = mi)
148
142
tuple_ind = pd.Index(tuples, tupleize_cols = False )
149
143
df_multi.index
150
144
@@ -183,7 +177,7 @@ API changes
183
177
184
178
.. code-block :: ipython
185
179
186
- In [1]: df = DataFrame(np.random.randn(10, 4), columns=list('ABCD'))
180
+ In [1]: df = pd. DataFrame(np.random.randn(10, 4), columns=list('ABCD'))
187
181
188
182
In [4]: covs = pd.rolling_cov(df[['A', 'B', 'C']],
189
183
....: df[['B', 'C', 'D']],
@@ -356,7 +350,7 @@ More consistent behaviour for some groupby methods:
356
350
357
351
.. ipython :: python
358
352
359
- df = DataFrame([[1 , np.nan], [1 , 4 ], [5 , 6 ]], columns = [' A' , ' B' ])
353
+ df = pd. DataFrame([[1 , np.nan], [1 , 4 ], [5 , 6 ]], columns = [' A' , ' B' ])
360
354
g = df.groupby(' A' )
361
355
g.nth(0 )
362
356
@@ -379,7 +373,7 @@ More consistent behaviour for some groupby methods:
379
373
380
374
.. ipython :: python
381
375
382
- df = DataFrame([[1 , np.nan], [1 , 4 ], [5 , 6 ], [5 , 8 ]], columns = [' A' , ' B' ])
376
+ df = pd. DataFrame([[1 , np.nan], [1 , 4 ], [5 , 6 ], [5 , 8 ]], columns = [' A' , ' B' ])
383
377
g = df.groupby(' A' )
384
378
g.count()
385
379
g.describe()
@@ -388,7 +382,7 @@ More consistent behaviour for some groupby methods:
388
382
389
383
.. ipython :: python
390
384
391
- df = DataFrame([[1 , np.nan], [1 , 4 ], [5 , 6 ], [5 , 8 ]], columns = [' A' , ' B' ])
385
+ df = pd. DataFrame([[1 , np.nan], [1 , 4 ], [5 , 6 ], [5 , 8 ]], columns = [' A' , ' B' ])
392
386
g = df.groupby(' A' , as_index = False )
393
387
g.count()
394
388
g.describe()
@@ -524,17 +518,17 @@ See also issues (:issue:`6134`, :issue:`4036`, :issue:`3057`, :issue:`2598`, :is
524
518
def mklbl (prefix , n ):
525
519
return [" %s%s " % (prefix, i) for i in range (n)]
526
520
527
- index = MultiIndex.from_product([mklbl(' A' , 4 ),
528
- mklbl(' B' , 2 ),
529
- mklbl(' C' , 4 ),
530
- mklbl(' D' , 2 )])
531
- columns = MultiIndex.from_tuples([(' a' , ' foo' ), (' a' , ' bar' ),
532
- (' b' , ' foo' ), (' b' , ' bah' )],
533
- names = [' lvl0' , ' lvl1' ])
534
- df = DataFrame(np.arange(len (index) * len (columns)).reshape((len (index),
535
- len (columns))),
536
- index = index,
537
- columns = columns).sort_index().sort_index(axis = 1 )
521
+ index = pd. MultiIndex.from_product([mklbl(' A' , 4 ),
522
+ mklbl(' B' , 2 ),
523
+ mklbl(' C' , 4 ),
524
+ mklbl(' D' , 2 )])
525
+ columns = pd. MultiIndex.from_tuples([(' a' , ' foo' ), (' a' , ' bar' ),
526
+ (' b' , ' foo' ), (' b' , ' bah' )],
527
+ names = [' lvl0' , ' lvl1' ])
528
+ df = pd. DataFrame(np.arange(len (index) * len (columns)).reshape((len (index),
529
+ len (columns))),
530
+ index = index,
531
+ columns = columns).sort_index().sort_index(axis = 1 )
538
532
df
539
533
540
534
Basic MultiIndex slicing using slices, lists, and labels.
@@ -682,25 +676,25 @@ Deprecations
682
676
.. code-block :: ipython
683
677
684
678
# non-floating point indexes can only be indexed by integers / labels
685
- In [1]: Series(1, np.arange(5))[3.0]
679
+ In [1]: pd. Series(1, np.arange(5))[3.0]
686
680
pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
687
681
Out[1]: 1
688
682
689
- In [2]: Series(1, np.arange(5)).iloc[3.0]
683
+ In [2]: pd. Series(1, np.arange(5)).iloc[3.0]
690
684
pandas/core/index.py:469: FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
691
685
Out[2]: 1
692
686
693
- In [3]: Series(1, np.arange(5)).iloc[3.0:4]
687
+ In [3]: pd. Series(1, np.arange(5)).iloc[3.0:4]
694
688
pandas/core/index.py:527: FutureWarning: slice indexers when using iloc should be integers and not floating point
695
689
Out[3]:
696
690
3 1
697
691
dtype: int64
698
692
699
693
# these are Float64Indexes, so integer or floating point is acceptable
700
- In [4]: Series(1, np.arange(5.))[3]
694
+ In [4]: pd. Series(1, np.arange(5.))[3]
701
695
Out[4]: 1
702
696
703
- In [5]: Series(1, np.arange(5.))[3.0]
697
+ In [5]: pd. Series(1, np.arange(5.))[3.0]
704
698
Out[6]: 1
705
699
706
700
- Numpy 1.9 compat w.r.t. deprecation warnings (:issue: `6960 `)
@@ -753,13 +747,13 @@ Enhancements
753
747
754
748
.. ipython :: python
755
749
756
- Series({(' a' , ' b' ): 1 , (' a' , ' a' ): 0 ,
757
- (' a' , ' c' ): 2 , (' b' , ' a' ): 3 , (' b' , ' b' ): 4 })
758
- DataFrame({(' a' , ' b' ): {(' A' , ' B' ): 1 , (' A' , ' C' ): 2 },
759
- (' a' , ' a' ): {(' A' , ' C' ): 3 , (' A' , ' B' ): 4 },
760
- (' a' , ' c' ): {(' A' , ' B' ): 5 , (' A' , ' C' ): 6 },
761
- (' b' , ' a' ): {(' A' , ' C' ): 7 , (' A' , ' B' ): 8 },
762
- (' b' , ' b' ): {(' A' , ' D' ): 9 , (' A' , ' B' ): 10 }})
750
+ pd. Series({(' a' , ' b' ): 1 , (' a' , ' a' ): 0 ,
751
+ (' a' , ' c' ): 2 , (' b' , ' a' ): 3 , (' b' , ' b' ): 4 })
752
+ pd. DataFrame({(' a' , ' b' ): {(' A' , ' B' ): 1 , (' A' , ' C' ): 2 },
753
+ (' a' , ' a' ): {(' A' , ' C' ): 3 , (' A' , ' B' ): 4 },
754
+ (' a' , ' c' ): {(' A' , ' B' ): 5 , (' A' , ' C' ): 6 },
755
+ (' b' , ' a' ): {(' A' , ' C' ): 7 , (' A' , ' B' ): 8 },
756
+ (' b' , ' b' ): {(' A' , ' D' ): 9 , (' A' , ' B' ): 10 }})
763
757
764
758
- Added the ``sym_diff `` method to ``Index `` (:issue: `5543 `)
765
759
- ``DataFrame.to_latex `` now takes a longtable keyword, which if True will return a table in a longtable environment. (:issue: `6617 `)
@@ -772,34 +766,34 @@ Enhancements
772
766
773
767
.. ipython :: python
774
768
775
- household = DataFrame({
776
- ' household_id' : [1 , 2 , 3 ],
777
- ' male' : [0 , 1 , 0 ],
778
- ' wealth' : [196087.3 , 316478.7 , 294750 ]
779
- },
780
- columns = [' household_id' , ' male' , ' wealth' ]
781
- ).set_index(' household_id' )
769
+ household = pd. DataFrame({
770
+ ' household_id' : [1 , 2 , 3 ],
771
+ ' male' : [0 , 1 , 0 ],
772
+ ' wealth' : [196087.3 , 316478.7 , 294750 ]
773
+ },
774
+ columns = [' household_id' , ' male' , ' wealth' ]
775
+ ).set_index(' household_id' )
782
776
household
783
- portfolio = DataFrame({
784
- ' household_id' : [1 , 2 , 2 , 3 , 3 , 3 , 4 ],
785
- ' asset_id' : [" nl0000301109" ,
786
- " nl0000289783" ,
787
- " gb00b03mlx29" ,
788
- " gb00b03mlx29" ,
789
- " lu0197800237" ,
790
- " nl0000289965" ,
791
- np.nan],
792
- ' name' : [" ABN Amro" ,
793
- " Robeco" ,
794
- " Royal Dutch Shell" ,
795
- " Royal Dutch Shell" ,
796
- " AAB Eastern Europe Equity Fund" ,
797
- " Postbank BioTech Fonds" ,
798
- np.nan],
799
- ' share' : [1.0 , 0.4 , 0.6 , 0.15 , 0.6 , 0.25 , 1.0 ]
800
- },
801
- columns = [' household_id' , ' asset_id' , ' name' , ' share' ]
802
- ).set_index([' household_id' , ' asset_id' ])
777
+ portfolio = pd. DataFrame({
778
+ ' household_id' : [1 , 2 , 2 , 3 , 3 , 3 , 4 ],
779
+ ' asset_id' : [" nl0000301109" ,
780
+ " nl0000289783" ,
781
+ " gb00b03mlx29" ,
782
+ " gb00b03mlx29" ,
783
+ " lu0197800237" ,
784
+ " nl0000289965" ,
785
+ np.nan],
786
+ ' name' : [" ABN Amro" ,
787
+ " Robeco" ,
788
+ " Royal Dutch Shell" ,
789
+ " Royal Dutch Shell" ,
790
+ " AAB Eastern Europe Equity Fund" ,
791
+ " Postbank BioTech Fonds" ,
792
+ np.nan],
793
+ ' share' : [1.0 , 0.4 , 0.6 , 0.15 , 0.6 , 0.25 , 1.0 ]
794
+ },
795
+ columns = [' household_id' , ' asset_id' , ' name' , ' share' ]
796
+ ).set_index([' household_id' , ' asset_id' ])
803
797
portfolio
804
798
805
799
household.join(portfolio, how = ' inner' )
@@ -834,7 +828,7 @@ Enhancements
834
828
.. ipython :: python
835
829
836
830
import datetime
837
- df = DataFrame({
831
+ df = pd. DataFrame({
838
832
' Branch' : ' A A A A A B' .split(),
839
833
' Buyer' : ' Carl Mark Carl Carl Joe Joe' .split(),
840
834
' Quantity' : [1 , 3 , 5 , 1 , 8 , 1 ],
@@ -857,9 +851,8 @@ Enhancements
857
851
858
852
.. ipython :: python
859
853
860
- import pandas.period_range as period_range
861
- prng = period_range(' 2013-01-01 09:00' , periods = 100 , freq = ' H' )
862
- ps = Series(np.random.randn(len (prng)), index = prng)
854
+ prng = pd.period_range(' 2013-01-01 09:00' , periods = 100 , freq = ' H' )
855
+ ps = pd.Series(np.random.randn(len (prng)), index = prng)
863
856
ps
864
857
ps[' 2013-01-02' ]
865
858
0 commit comments