@@ -369,10 +369,10 @@ def values(self):
369
369
Timezone aware datetime data is converted to UTC:
370
370
371
371
>>> pd.Series(pd.date_range('20130101', periods=3,
372
- tz='US/Eastern')).values
373
- array(['2013-01-01T00 :00:00.000000000-0500 ',
374
- '2013-01-02T00 :00:00.000000000-0500 ',
375
- '2013-01-03T00 :00:00.000000000-0500 '], dtype='datetime64[ns]')
372
+ ... tz='US/Eastern')).values
373
+ array(['2013-01-01T05 :00:00.000000000',
374
+ '2013-01-02T05 :00:00.000000000',
375
+ '2013-01-03T05 :00:00.000000000'], dtype='datetime64[ns]')
376
376
377
377
"""
378
378
return self ._data .external_values ()
@@ -1550,6 +1550,8 @@ def append(self, to_append, ignore_index=False, verify_integrity=False):
1550
1550
With `verify_integrity` set to True:
1551
1551
1552
1552
>>> s1.append(s2, verify_integrity=True)
1553
+ Traceback (most recent call last):
1554
+ ...
1553
1555
ValueError: Indexes have overlapping values: [0, 1, 2]
1554
1556
1555
1557
@@ -1919,8 +1921,19 @@ def nlargest(self, n=5, keep='first'):
1919
1921
--------
1920
1922
>>> import pandas as pd
1921
1923
>>> import numpy as np
1922
- >>> s = pd.Series(np.random.randn(1e6 ))
1924
+ >>> s = pd.Series(np.random.randn(10**6 ))
1923
1925
>>> s.nlargest(10) # only sorts up to the N requested
1926
+ 219921 4.644710
1927
+ 82124 4.608745
1928
+ 421689 4.564644
1929
+ 425277 4.447014
1930
+ 718691 4.414137
1931
+ 43154 4.403520
1932
+ 283187 4.313922
1933
+ 595519 4.273635
1934
+ 503969 4.250236
1935
+ 121637 4.240952
1936
+ dtype: float64
1924
1937
"""
1925
1938
return algorithms .select_n_series (self , n = n , keep = keep ,
1926
1939
method = 'nlargest' )
@@ -1958,8 +1971,19 @@ def nsmallest(self, n=5, keep='first'):
1958
1971
--------
1959
1972
>>> import pandas as pd
1960
1973
>>> import numpy as np
1961
- >>> s = pd.Series(np.random.randn(1e6 ))
1974
+ >>> s = pd.Series(np.random.randn(10**6 ))
1962
1975
>>> s.nsmallest(10) # only sorts up to the N requested
1976
+ 288532 -4.954580
1977
+ 732345 -4.835960
1978
+ 64803 -4.812550
1979
+ 446457 -4.609998
1980
+ 501225 -4.483945
1981
+ 669476 -4.472935
1982
+ 973615 -4.401699
1983
+ 621279 -4.355126
1984
+ 773916 -4.347355
1985
+ 359919 -4.331927
1986
+ dtype: float64
1963
1987
"""
1964
1988
return algorithms .select_n_series (self , n = n , keep = keep ,
1965
1989
method = 'nsmallest' )
@@ -2052,21 +2076,24 @@ def unstack(self, level=-1, fill_value=None):
2052
2076
2053
2077
Examples
2054
2078
--------
2079
+ >>> s = pd.Series([1, 2, 3, 4],
2080
+ ... index=pd.MultiIndex.from_product([['one', 'two'], ['a', 'b']]))
2055
2081
>>> s
2056
- one a 1.
2057
- one b 2.
2058
- two a 3.
2059
- two b 4.
2082
+ one a 1
2083
+ b 2
2084
+ two a 3
2085
+ b 4
2086
+ dtype: int64
2060
2087
2061
2088
>>> s.unstack(level=-1)
2062
- a b
2063
- one 1. 2.
2064
- two 3. 4.
2089
+ a b
2090
+ one 1 2
2091
+ two 3 4
2065
2092
2066
2093
>>> s.unstack(level=0)
2067
2094
one two
2068
- a 1. 2.
2069
- b 3. 4.
2095
+ a 1 3
2096
+ b 2 4
2070
2097
2071
2098
Returns
2072
2099
-------
@@ -2102,15 +2129,16 @@ def map(self, arg, na_action=None):
2102
2129
2103
2130
>>> x = pd.Series([1,2,3], index=['one', 'two', 'three'])
2104
2131
>>> x
2105
- one 1
2106
- two 2
2107
- three 3
2132
+ one 1
2133
+ two 2
2134
+ three 3
2135
+ dtype: int64
2108
2136
2109
2137
>>> y = pd.Series(['foo', 'bar', 'baz'], index=[1,2,3])
2110
2138
>>> y
2111
- 1 foo
2112
- 2 bar
2113
- 3 baz
2139
+ 1 foo
2140
+ 2 bar
2141
+ 3 baz
2114
2142
2115
2143
>>> x.map(y)
2116
2144
one foo
@@ -2215,6 +2243,7 @@ def apply(self, func, convert_dtype=True, args=(), **kwds):
2215
2243
>>> import numpy as np
2216
2244
>>> series = pd.Series([20, 21, 12], index=['London',
2217
2245
... 'New York','Helsinki'])
2246
+ >>> series
2218
2247
London 20
2219
2248
New York 21
2220
2249
Helsinki 12
0 commit comments