body_hash stringlengths 64 64 | body stringlengths 23 109k | docstring stringlengths 1 57k | path stringlengths 4 198 | name stringlengths 1 115 | repository_name stringlengths 7 111 | repository_stars float64 0 191k | lang stringclasses 1 value | body_without_docstring stringlengths 14 108k | unified stringlengths 45 133k |
|---|---|---|---|---|---|---|---|---|---|
bc05cd87716235523ab4b0dcefc94c3983f930d4f161f207f860ff9c13e2e23b | def rtruediv(self, other, fill_value=None, axis=0):
"Floating division of series and other, element-wise\n (binary operator rtruediv).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd'])\n >>> a\n a 10\n b 20\n c <NA>\n d 30\n dtype: int64\n >>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e'])\n >>> b\n a 1\n b <NA>\n d 2\n e 3\n dtype: int64\n >>> a.rtruediv(b, fill_value=0)\n a 0.1\n b 0.0\n c <NA>\n d 0.066666667\n e Inf\n dtype: float64\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other, 'truediv', fill_value, True) | Floating division of series and other, element-wise
(binary operator rtruediv).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd'])
>>> a
a 10
b 20
c <NA>
d 30
dtype: int64
>>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e'])
>>> b
a 1
b <NA>
d 2
e 3
dtype: int64
>>> a.rtruediv(b, fill_value=0)
a 0.1
b 0.0
c <NA>
d 0.066666667
e Inf
dtype: float64 | python/cudf/cudf/core/series.py | rtruediv | jdye64/cudf | 1 | python | def rtruediv(self, other, fill_value=None, axis=0):
"Floating division of series and other, element-wise\n (binary operator rtruediv).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd'])\n >>> a\n a 10\n b 20\n c <NA>\n d 30\n dtype: int64\n >>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e'])\n >>> b\n a 1\n b <NA>\n d 2\n e 3\n dtype: int64\n >>> a.rtruediv(b, fill_value=0)\n a 0.1\n b 0.0\n c <NA>\n d 0.066666667\n e Inf\n dtype: float64\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other, 'truediv', fill_value, True) | def rtruediv(self, other, fill_value=None, axis=0):
"Floating division of series and other, element-wise\n (binary operator rtruediv).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd'])\n >>> a\n a 10\n b 20\n c <NA>\n d 30\n dtype: int64\n >>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e'])\n >>> b\n a 1\n b <NA>\n d 2\n e 3\n dtype: int64\n >>> a.rtruediv(b, fill_value=0)\n a 0.1\n b 0.0\n c <NA>\n d 0.066666667\n e Inf\n dtype: float64\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other, 'truediv', fill_value, True)<|docstring|>Floating division of series and other, element-wise
(binary operator rtruediv).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd'])
>>> a
a 10
b 20
c <NA>
d 30
dtype: int64
>>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e'])
>>> b
a 1
b <NA>
d 2
e 3
dtype: int64
>>> a.rtruediv(b, fill_value=0)
a 0.1
b 0.0
c <NA>
d 0.066666667
e Inf
dtype: float64<|endoftext|> |
6397ac51382fe2db1c8513f0407cd89835f6306a8fb9796b12854071f79f5921 | def eq(self, other, fill_value=None, axis=0):
"Equal to of series and other, element-wise\n (binary operator eq).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.eq(b, fill_value=2)\n a False\n b False\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='eq', fill_value=fill_value, can_reindex=True) | Equal to of series and other, element-wise
(binary operator eq).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.eq(b, fill_value=2)
a False
b False
c False
d False
e <NA>
f False
g False
dtype: bool | python/cudf/cudf/core/series.py | eq | jdye64/cudf | 1 | python | def eq(self, other, fill_value=None, axis=0):
"Equal to of series and other, element-wise\n (binary operator eq).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.eq(b, fill_value=2)\n a False\n b False\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='eq', fill_value=fill_value, can_reindex=True) | def eq(self, other, fill_value=None, axis=0):
"Equal to of series and other, element-wise\n (binary operator eq).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.eq(b, fill_value=2)\n a False\n b False\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='eq', fill_value=fill_value, can_reindex=True)<|docstring|>Equal to of series and other, element-wise
(binary operator eq).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.eq(b, fill_value=2)
a False
b False
c False
d False
e <NA>
f False
g False
dtype: bool<|endoftext|> |
e096f8da2e4d954bc3031c76ff18e7366640b0143c3c58df181188c63ae327ba | def ne(self, other, fill_value=None, axis=0):
"Not equal to of series and other, element-wise\n (binary operator ne).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.ne(b, fill_value=2)\n a True\n b True\n c True\n d True\n e <NA>\n f True\n g True\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='ne', fill_value=fill_value, can_reindex=True) | Not equal to of series and other, element-wise
(binary operator ne).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.ne(b, fill_value=2)
a True
b True
c True
d True
e <NA>
f True
g True
dtype: bool | python/cudf/cudf/core/series.py | ne | jdye64/cudf | 1 | python | def ne(self, other, fill_value=None, axis=0):
"Not equal to of series and other, element-wise\n (binary operator ne).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.ne(b, fill_value=2)\n a True\n b True\n c True\n d True\n e <NA>\n f True\n g True\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='ne', fill_value=fill_value, can_reindex=True) | def ne(self, other, fill_value=None, axis=0):
"Not equal to of series and other, element-wise\n (binary operator ne).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.ne(b, fill_value=2)\n a True\n b True\n c True\n d True\n e <NA>\n f True\n g True\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='ne', fill_value=fill_value, can_reindex=True)<|docstring|>Not equal to of series and other, element-wise
(binary operator ne).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.ne(b, fill_value=2)
a True
b True
c True
d True
e <NA>
f True
g True
dtype: bool<|endoftext|> |
846f3bcb6a7ba07915c4f7fb213d9aeddcf8c0e1ab8426d75efe0b8190e2827c | def lt(self, other, fill_value=None, axis=0):
"Less than of series and other, element-wise\n (binary operator lt).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.lt(b, fill_value=-10)\n a False\n b True\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='lt', fill_value=fill_value, can_reindex=True) | Less than of series and other, element-wise
(binary operator lt).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.lt(b, fill_value=-10)
a False
b True
c False
d False
e <NA>
f False
g False
dtype: bool | python/cudf/cudf/core/series.py | lt | jdye64/cudf | 1 | python | def lt(self, other, fill_value=None, axis=0):
"Less than of series and other, element-wise\n (binary operator lt).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.lt(b, fill_value=-10)\n a False\n b True\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='lt', fill_value=fill_value, can_reindex=True) | def lt(self, other, fill_value=None, axis=0):
"Less than of series and other, element-wise\n (binary operator lt).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.lt(b, fill_value=-10)\n a False\n b True\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='lt', fill_value=fill_value, can_reindex=True)<|docstring|>Less than of series and other, element-wise
(binary operator lt).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.lt(b, fill_value=-10)
a False
b True
c False
d False
e <NA>
f False
g False
dtype: bool<|endoftext|> |
d1729036261350e6aaf41523624f7d20f3ddd1ef162b8f945704bf1e84b0e1d6 | def le(self, other, fill_value=None, axis=0):
"Less than or equal to of series and other, element-wise\n (binary operator le).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.le(b, fill_value=-10)\n a False\n b True\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='le', fill_value=fill_value, can_reindex=True) | Less than or equal to of series and other, element-wise
(binary operator le).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.le(b, fill_value=-10)
a False
b True
c False
d False
e <NA>
f False
g False
dtype: bool | python/cudf/cudf/core/series.py | le | jdye64/cudf | 1 | python | def le(self, other, fill_value=None, axis=0):
"Less than or equal to of series and other, element-wise\n (binary operator le).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.le(b, fill_value=-10)\n a False\n b True\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='le', fill_value=fill_value, can_reindex=True) | def le(self, other, fill_value=None, axis=0):
"Less than or equal to of series and other, element-wise\n (binary operator le).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.le(b, fill_value=-10)\n a False\n b True\n c False\n d False\n e <NA>\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='le', fill_value=fill_value, can_reindex=True)<|docstring|>Less than or equal to of series and other, element-wise
(binary operator le).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.le(b, fill_value=-10)
a False
b True
c False
d False
e <NA>
f False
g False
dtype: bool<|endoftext|> |
2859df3fa6ffd1893cc5070377477f785097dbcd67e7cdb559945c9ba5262006 | def gt(self, other, fill_value=None, axis=0):
"Greater than of series and other, element-wise\n (binary operator gt).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.gt(b)\n a True\n b False\n c True\n d False\n e False\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='gt', fill_value=fill_value, can_reindex=True) | Greater than of series and other, element-wise
(binary operator gt).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.gt(b)
a True
b False
c True
d False
e False
f False
g False
dtype: bool | python/cudf/cudf/core/series.py | gt | jdye64/cudf | 1 | python | def gt(self, other, fill_value=None, axis=0):
"Greater than of series and other, element-wise\n (binary operator gt).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.gt(b)\n a True\n b False\n c True\n d False\n e False\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='gt', fill_value=fill_value, can_reindex=True) | def gt(self, other, fill_value=None, axis=0):
"Greater than of series and other, element-wise\n (binary operator gt).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.gt(b)\n a True\n b False\n c True\n d False\n e False\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='gt', fill_value=fill_value, can_reindex=True)<|docstring|>Greater than of series and other, element-wise
(binary operator gt).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.gt(b)
a True
b False
c True
d False
e False
f False
g False
dtype: bool<|endoftext|> |
2ab392dace0e301f652b957fea9a86083519a8ffe2450fc3dbea52a23cb9a922 | def ge(self, other, fill_value=None, axis=0):
"Greater than or equal to of series and other, element-wise\n (binary operator ge).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.ge(b)\n a True\n b False\n c True\n d False\n e False\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='ge', fill_value=fill_value, can_reindex=True) | Greater than or equal to of series and other, element-wise
(binary operator ge).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.ge(b)
a True
b False
c True
d False
e False
f False
g False
dtype: bool | python/cudf/cudf/core/series.py | ge | jdye64/cudf | 1 | python | def ge(self, other, fill_value=None, axis=0):
"Greater than or equal to of series and other, element-wise\n (binary operator ge).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.ge(b)\n a True\n b False\n c True\n d False\n e False\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='ge', fill_value=fill_value, can_reindex=True) | def ge(self, other, fill_value=None, axis=0):
"Greater than or equal to of series and other, element-wise\n (binary operator ge).\n\n Parameters\n ----------\n other : Series or scalar value\n fill_value : None or value\n Value to fill nulls with before computation. If data in both\n corresponding Series locations is null the result will be null\n\n Returns\n -------\n Series\n The result of the operation.\n\n Examples\n --------\n >>> import cudf\n >>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])\n >>> a\n a 1\n c 2\n d 3\n e <NA>\n f 10\n g 20\n dtype: int64\n >>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])\n >>> b\n a -10\n b 23\n c -1\n d <NA>\n e <NA>\n dtype: int64\n >>> a.ge(b)\n a True\n b False\n c True\n d False\n e False\n f False\n g False\n dtype: bool\n "
if (axis != 0):
raise NotImplementedError('Only axis=0 supported at this time.')
return self._binaryop(other=other, fn='ge', fill_value=fill_value, can_reindex=True)<|docstring|>Greater than or equal to of series and other, element-wise
(binary operator ge).
Parameters
----------
other : Series or scalar value
fill_value : None or value
Value to fill nulls with before computation. If data in both
corresponding Series locations is null the result will be null
Returns
-------
Series
The result of the operation.
Examples
--------
>>> import cudf
>>> a = cudf.Series([1, 2, 3, None, 10, 20], index=['a', 'c', 'd', 'e', 'f', 'g'])
>>> a
a 1
c 2
d 3
e <NA>
f 10
g 20
dtype: int64
>>> b = cudf.Series([-10, 23, -1, None, None], index=['a', 'b', 'c', 'd', 'e'])
>>> b
a -10
b 23
c -1
d <NA>
e <NA>
dtype: int64
>>> a.ge(b)
a True
b False
c True
d False
e False
f False
g False
dtype: bool<|endoftext|> |
1f2c6407ba9eabd929748b8c6337ec04982e87473b9d8308580f3ccb455a5de2 | @property
def dtype(self):
'dtype of the Series'
return self._column.dtype | dtype of the Series | python/cudf/cudf/core/series.py | dtype | jdye64/cudf | 1 | python | @property
def dtype(self):
return self._column.dtype | @property
def dtype(self):
return self._column.dtype<|docstring|>dtype of the Series<|endoftext|> |
6d62e535c6e38bdf7abcc40cc76cf29c5e24768433526bca2cf4428709dd8b69 | @property
def valid_count(self):
'Number of non-null values'
return self._column.valid_count | Number of non-null values | python/cudf/cudf/core/series.py | valid_count | jdye64/cudf | 1 | python | @property
def valid_count(self):
return self._column.valid_count | @property
def valid_count(self):
return self._column.valid_count<|docstring|>Number of non-null values<|endoftext|> |
893ff8f0e18297bca3400d8bfd7896f0703049c2acbb02b7061ae902f739b3aa | @property
def null_count(self):
'Number of null values'
return self._column.null_count | Number of null values | python/cudf/cudf/core/series.py | null_count | jdye64/cudf | 1 | python | @property
def null_count(self):
return self._column.null_count | @property
def null_count(self):
return self._column.null_count<|docstring|>Number of null values<|endoftext|> |
2f640c90b76449e126b580503d6bd1ed100605b12408655b4752f10cbc525cfd | @property
def nullable(self):
'A boolean indicating whether a null-mask is needed'
return self._column.nullable | A boolean indicating whether a null-mask is needed | python/cudf/cudf/core/series.py | nullable | jdye64/cudf | 1 | python | @property
def nullable(self):
return self._column.nullable | @property
def nullable(self):
return self._column.nullable<|docstring|>A boolean indicating whether a null-mask is needed<|endoftext|> |
cfa85424ecb15aa48987359a21137b2ae9d71d1669624bd21d54c1f627331e7e | @property
def has_nulls(self):
'\n Indicator whether Series contains null values.\n\n Returns\n -------\n out : bool\n If Series has atleast one null value, return True, if not\n return False.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, None, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 <NA>\n 3 3\n 4 4\n dtype: int64\n >>> series.has_nulls\n True\n >>> series.dropna().has_nulls\n False\n '
return self._column.has_nulls | Indicator whether Series contains null values.
Returns
-------
out : bool
If Series has atleast one null value, return True, if not
return False.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, None, 3, 4])
>>> series
0 1
1 2
2 <NA>
3 3
4 4
dtype: int64
>>> series.has_nulls
True
>>> series.dropna().has_nulls
False | python/cudf/cudf/core/series.py | has_nulls | jdye64/cudf | 1 | python | @property
def has_nulls(self):
'\n Indicator whether Series contains null values.\n\n Returns\n -------\n out : bool\n If Series has atleast one null value, return True, if not\n return False.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, None, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 <NA>\n 3 3\n 4 4\n dtype: int64\n >>> series.has_nulls\n True\n >>> series.dropna().has_nulls\n False\n '
return self._column.has_nulls | @property
def has_nulls(self):
'\n Indicator whether Series contains null values.\n\n Returns\n -------\n out : bool\n If Series has atleast one null value, return True, if not\n return False.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, None, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 <NA>\n 3 3\n 4 4\n dtype: int64\n >>> series.has_nulls\n True\n >>> series.dropna().has_nulls\n False\n '
return self._column.has_nulls<|docstring|>Indicator whether Series contains null values.
Returns
-------
out : bool
If Series has atleast one null value, return True, if not
return False.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, None, 3, 4])
>>> series
0 1
1 2
2 <NA>
3 3
4 4
dtype: int64
>>> series.has_nulls
True
>>> series.dropna().has_nulls
False<|endoftext|> |
e18647d2282073ab440ff2bf71aee5510cb5510397e18a8cae8ae881bd1bf36c | def dropna(self, axis=0, inplace=False, how=None):
"\n Return a Series with null values removed.\n\n Parameters\n ----------\n axis : {0 or ‘index’}, default 0\n There is only one axis to drop values from.\n inplace : bool, default False\n If True, do operation inplace and return None.\n how : str, optional\n Not in use. Kept for compatibility.\n\n Returns\n -------\n Series\n Series with null entries dropped from it.\n\n See Also\n --------\n Series.isna : Indicate null values.\n\n Series.notna : Indicate non-null values.\n\n Series.fillna : Replace null values.\n\n cudf.DataFrame.dropna : Drop rows or columns which\n contain null values.\n\n cudf.Index.dropna : Drop null indices.\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([1, 2, None])\n >>> ser\n 0 1\n 1 2\n 2 null\n dtype: int64\n\n Drop null values from a Series.\n\n >>> ser.dropna()\n 0 1\n 1 2\n dtype: int64\n\n Keep the Series with valid entries in the same variable.\n\n >>> ser.dropna(inplace=True)\n >>> ser\n 0 1\n 1 2\n dtype: int64\n\n Empty strings are not considered null values.\n `None` is considered a null value.\n\n >>> ser = cudf.Series(['', None, 'abc'])\n >>> ser\n 0\n 1 <NA>\n 2 abc\n dtype: object\n >>> ser.dropna()\n 0\n 2 abc\n dtype: object\n "
if (axis not in (0, 'index')):
raise ValueError('Series.dropna supports only one axis to drop values from')
result = super().dropna(axis=axis)
return self._mimic_inplace(result, inplace=inplace) | Return a Series with null values removed.
Parameters
----------
axis : {0 or ‘index’}, default 0
There is only one axis to drop values from.
inplace : bool, default False
If True, do operation inplace and return None.
how : str, optional
Not in use. Kept for compatibility.
Returns
-------
Series
Series with null entries dropped from it.
See Also
--------
Series.isna : Indicate null values.
Series.notna : Indicate non-null values.
Series.fillna : Replace null values.
cudf.DataFrame.dropna : Drop rows or columns which
contain null values.
cudf.Index.dropna : Drop null indices.
Examples
--------
>>> import cudf
>>> ser = cudf.Series([1, 2, None])
>>> ser
0 1
1 2
2 null
dtype: int64
Drop null values from a Series.
>>> ser.dropna()
0 1
1 2
dtype: int64
Keep the Series with valid entries in the same variable.
>>> ser.dropna(inplace=True)
>>> ser
0 1
1 2
dtype: int64
Empty strings are not considered null values.
`None` is considered a null value.
>>> ser = cudf.Series(['', None, 'abc'])
>>> ser
0
1 <NA>
2 abc
dtype: object
>>> ser.dropna()
0
2 abc
dtype: object | python/cudf/cudf/core/series.py | dropna | jdye64/cudf | 1 | python | def dropna(self, axis=0, inplace=False, how=None):
"\n Return a Series with null values removed.\n\n Parameters\n ----------\n axis : {0 or ‘index’}, default 0\n There is only one axis to drop values from.\n inplace : bool, default False\n If True, do operation inplace and return None.\n how : str, optional\n Not in use. Kept for compatibility.\n\n Returns\n -------\n Series\n Series with null entries dropped from it.\n\n See Also\n --------\n Series.isna : Indicate null values.\n\n Series.notna : Indicate non-null values.\n\n Series.fillna : Replace null values.\n\n cudf.DataFrame.dropna : Drop rows or columns which\n contain null values.\n\n cudf.Index.dropna : Drop null indices.\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([1, 2, None])\n >>> ser\n 0 1\n 1 2\n 2 null\n dtype: int64\n\n Drop null values from a Series.\n\n >>> ser.dropna()\n 0 1\n 1 2\n dtype: int64\n\n Keep the Series with valid entries in the same variable.\n\n >>> ser.dropna(inplace=True)\n >>> ser\n 0 1\n 1 2\n dtype: int64\n\n Empty strings are not considered null values.\n `None` is considered a null value.\n\n >>> ser = cudf.Series([, None, 'abc'])\n >>> ser\n 0\n 1 <NA>\n 2 abc\n dtype: object\n >>> ser.dropna()\n 0\n 2 abc\n dtype: object\n "
if (axis not in (0, 'index')):
raise ValueError('Series.dropna supports only one axis to drop values from')
result = super().dropna(axis=axis)
return self._mimic_inplace(result, inplace=inplace) | def dropna(self, axis=0, inplace=False, how=None):
"\n Return a Series with null values removed.\n\n Parameters\n ----------\n axis : {0 or ‘index’}, default 0\n There is only one axis to drop values from.\n inplace : bool, default False\n If True, do operation inplace and return None.\n how : str, optional\n Not in use. Kept for compatibility.\n\n Returns\n -------\n Series\n Series with null entries dropped from it.\n\n See Also\n --------\n Series.isna : Indicate null values.\n\n Series.notna : Indicate non-null values.\n\n Series.fillna : Replace null values.\n\n cudf.DataFrame.dropna : Drop rows or columns which\n contain null values.\n\n cudf.Index.dropna : Drop null indices.\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([1, 2, None])\n >>> ser\n 0 1\n 1 2\n 2 null\n dtype: int64\n\n Drop null values from a Series.\n\n >>> ser.dropna()\n 0 1\n 1 2\n dtype: int64\n\n Keep the Series with valid entries in the same variable.\n\n >>> ser.dropna(inplace=True)\n >>> ser\n 0 1\n 1 2\n dtype: int64\n\n Empty strings are not considered null values.\n `None` is considered a null value.\n\n >>> ser = cudf.Series([, None, 'abc'])\n >>> ser\n 0\n 1 <NA>\n 2 abc\n dtype: object\n >>> ser.dropna()\n 0\n 2 abc\n dtype: object\n "
if (axis not in (0, 'index')):
raise ValueError('Series.dropna supports only one axis to drop values from')
result = super().dropna(axis=axis)
return self._mimic_inplace(result, inplace=inplace)<|docstring|>Return a Series with null values removed.
Parameters
----------
axis : {0 or ‘index’}, default 0
There is only one axis to drop values from.
inplace : bool, default False
If True, do operation inplace and return None.
how : str, optional
Not in use. Kept for compatibility.
Returns
-------
Series
Series with null entries dropped from it.
See Also
--------
Series.isna : Indicate null values.
Series.notna : Indicate non-null values.
Series.fillna : Replace null values.
cudf.DataFrame.dropna : Drop rows or columns which
contain null values.
cudf.Index.dropna : Drop null indices.
Examples
--------
>>> import cudf
>>> ser = cudf.Series([1, 2, None])
>>> ser
0 1
1 2
2 null
dtype: int64
Drop null values from a Series.
>>> ser.dropna()
0 1
1 2
dtype: int64
Keep the Series with valid entries in the same variable.
>>> ser.dropna(inplace=True)
>>> ser
0 1
1 2
dtype: int64
Empty strings are not considered null values.
`None` is considered a null value.
>>> ser = cudf.Series(['', None, 'abc'])
>>> ser
0
1 <NA>
2 abc
dtype: object
>>> ser.dropna()
0
2 abc
dtype: object<|endoftext|> |
aaf9593de03527f8b653095a808835ea3f089026ab688d43b7387ecd3df4315d | def drop_duplicates(self, keep='first', inplace=False, ignore_index=False):
"\n Return Series with duplicate values removed.\n\n Parameters\n ----------\n keep : {'first', 'last', ``False``}, default 'first'\n Method to handle dropping duplicates:\n\n - 'first' : Drop duplicates except for the first occurrence.\n - 'last' : Drop duplicates except for the last occurrence.\n - ``False`` : Drop all duplicates.\n\n inplace : bool, default ``False``\n If ``True``, performs operation inplace and returns None.\n\n Returns\n -------\n Series or None\n Series with duplicates dropped or None if ``inplace=True``.\n\n Examples\n --------\n >>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],\n ... name='animal')\n >>> s\n 0 lama\n 1 cow\n 2 lama\n 3 beetle\n 4 lama\n 5 hippo\n Name: animal, dtype: object\n\n With the `keep` parameter, the selection behaviour of duplicated\n values can be changed. The value ‘first’ keeps the first\n occurrence for each set of duplicated entries.\n The default value of keep is ‘first’. Note that order of\n the rows being returned is not guaranteed\n to be sorted.\n\n >>> s.drop_duplicates()\n 3 beetle\n 1 cow\n 5 hippo\n 0 lama\n Name: animal, dtype: object\n\n The value ‘last’ for parameter `keep` keeps the last occurrence\n for each set of duplicated entries.\n\n >>> s.drop_duplicates(keep='last')\n 3 beetle\n 1 cow\n 5 hippo\n 4 lama\n Name: animal, dtype: object\n\n The value `False` for parameter `keep` discards all sets\n of duplicated entries. Setting the value of ‘inplace’ to\n `True` performs the operation inplace and returns `None`.\n\n >>> s.drop_duplicates(keep=False, inplace=True)\n >>> s\n 3 beetle\n 1 cow\n 5 hippo\n Name: animal, dtype: object\n "
result = super().drop_duplicates(keep=keep, ignore_index=ignore_index)
return self._mimic_inplace(result, inplace=inplace) | Return Series with duplicate values removed.
Parameters
----------
keep : {'first', 'last', ``False``}, default 'first'
Method to handle dropping duplicates:
- 'first' : Drop duplicates except for the first occurrence.
- 'last' : Drop duplicates except for the last occurrence.
- ``False`` : Drop all duplicates.
inplace : bool, default ``False``
If ``True``, performs operation inplace and returns None.
Returns
-------
Series or None
Series with duplicates dropped or None if ``inplace=True``.
Examples
--------
>>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],
... name='animal')
>>> s
0 lama
1 cow
2 lama
3 beetle
4 lama
5 hippo
Name: animal, dtype: object
With the `keep` parameter, the selection behaviour of duplicated
values can be changed. The value ‘first’ keeps the first
occurrence for each set of duplicated entries.
The default value of keep is ‘first’. Note that order of
the rows being returned is not guaranteed
to be sorted.
>>> s.drop_duplicates()
3 beetle
1 cow
5 hippo
0 lama
Name: animal, dtype: object
The value ‘last’ for parameter `keep` keeps the last occurrence
for each set of duplicated entries.
>>> s.drop_duplicates(keep='last')
3 beetle
1 cow
5 hippo
4 lama
Name: animal, dtype: object
The value `False` for parameter `keep` discards all sets
of duplicated entries. Setting the value of ‘inplace’ to
`True` performs the operation inplace and returns `None`.
>>> s.drop_duplicates(keep=False, inplace=True)
>>> s
3 beetle
1 cow
5 hippo
Name: animal, dtype: object | python/cudf/cudf/core/series.py | drop_duplicates | jdye64/cudf | 1 | python | def drop_duplicates(self, keep='first', inplace=False, ignore_index=False):
"\n Return Series with duplicate values removed.\n\n Parameters\n ----------\n keep : {'first', 'last', ``False``}, default 'first'\n Method to handle dropping duplicates:\n\n - 'first' : Drop duplicates except for the first occurrence.\n - 'last' : Drop duplicates except for the last occurrence.\n - ``False`` : Drop all duplicates.\n\n inplace : bool, default ``False``\n If ``True``, performs operation inplace and returns None.\n\n Returns\n -------\n Series or None\n Series with duplicates dropped or None if ``inplace=True``.\n\n Examples\n --------\n >>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],\n ... name='animal')\n >>> s\n 0 lama\n 1 cow\n 2 lama\n 3 beetle\n 4 lama\n 5 hippo\n Name: animal, dtype: object\n\n With the `keep` parameter, the selection behaviour of duplicated\n values can be changed. The value ‘first’ keeps the first\n occurrence for each set of duplicated entries.\n The default value of keep is ‘first’. Note that order of\n the rows being returned is not guaranteed\n to be sorted.\n\n >>> s.drop_duplicates()\n 3 beetle\n 1 cow\n 5 hippo\n 0 lama\n Name: animal, dtype: object\n\n The value ‘last’ for parameter `keep` keeps the last occurrence\n for each set of duplicated entries.\n\n >>> s.drop_duplicates(keep='last')\n 3 beetle\n 1 cow\n 5 hippo\n 4 lama\n Name: animal, dtype: object\n\n The value `False` for parameter `keep` discards all sets\n of duplicated entries. Setting the value of ‘inplace’ to\n `True` performs the operation inplace and returns `None`.\n\n >>> s.drop_duplicates(keep=False, inplace=True)\n >>> s\n 3 beetle\n 1 cow\n 5 hippo\n Name: animal, dtype: object\n "
result = super().drop_duplicates(keep=keep, ignore_index=ignore_index)
return self._mimic_inplace(result, inplace=inplace) | def drop_duplicates(self, keep='first', inplace=False, ignore_index=False):
"\n Return Series with duplicate values removed.\n\n Parameters\n ----------\n keep : {'first', 'last', ``False``}, default 'first'\n Method to handle dropping duplicates:\n\n - 'first' : Drop duplicates except for the first occurrence.\n - 'last' : Drop duplicates except for the last occurrence.\n - ``False`` : Drop all duplicates.\n\n inplace : bool, default ``False``\n If ``True``, performs operation inplace and returns None.\n\n Returns\n -------\n Series or None\n Series with duplicates dropped or None if ``inplace=True``.\n\n Examples\n --------\n >>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],\n ... name='animal')\n >>> s\n 0 lama\n 1 cow\n 2 lama\n 3 beetle\n 4 lama\n 5 hippo\n Name: animal, dtype: object\n\n With the `keep` parameter, the selection behaviour of duplicated\n values can be changed. The value ‘first’ keeps the first\n occurrence for each set of duplicated entries.\n The default value of keep is ‘first’. Note that order of\n the rows being returned is not guaranteed\n to be sorted.\n\n >>> s.drop_duplicates()\n 3 beetle\n 1 cow\n 5 hippo\n 0 lama\n Name: animal, dtype: object\n\n The value ‘last’ for parameter `keep` keeps the last occurrence\n for each set of duplicated entries.\n\n >>> s.drop_duplicates(keep='last')\n 3 beetle\n 1 cow\n 5 hippo\n 4 lama\n Name: animal, dtype: object\n\n The value `False` for parameter `keep` discards all sets\n of duplicated entries. Setting the value of ‘inplace’ to\n `True` performs the operation inplace and returns `None`.\n\n >>> s.drop_duplicates(keep=False, inplace=True)\n >>> s\n 3 beetle\n 1 cow\n 5 hippo\n Name: animal, dtype: object\n "
result = super().drop_duplicates(keep=keep, ignore_index=ignore_index)
return self._mimic_inplace(result, inplace=inplace)<|docstring|>Return Series with duplicate values removed.
Parameters
----------
keep : {'first', 'last', ``False``}, default 'first'
Method to handle dropping duplicates:
- 'first' : Drop duplicates except for the first occurrence.
- 'last' : Drop duplicates except for the last occurrence.
- ``False`` : Drop all duplicates.
inplace : bool, default ``False``
If ``True``, performs operation inplace and returns None.
Returns
-------
Series or None
Series with duplicates dropped or None if ``inplace=True``.
Examples
--------
>>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'],
... name='animal')
>>> s
0 lama
1 cow
2 lama
3 beetle
4 lama
5 hippo
Name: animal, dtype: object
With the `keep` parameter, the selection behaviour of duplicated
values can be changed. The value ‘first’ keeps the first
occurrence for each set of duplicated entries.
The default value of keep is ‘first’. Note that order of
the rows being returned is not guaranteed
to be sorted.
>>> s.drop_duplicates()
3 beetle
1 cow
5 hippo
0 lama
Name: animal, dtype: object
The value ‘last’ for parameter `keep` keeps the last occurrence
for each set of duplicated entries.
>>> s.drop_duplicates(keep='last')
3 beetle
1 cow
5 hippo
4 lama
Name: animal, dtype: object
The value `False` for parameter `keep` discards all sets
of duplicated entries. Setting the value of ‘inplace’ to
`True` performs the operation inplace and returns `None`.
>>> s.drop_duplicates(keep=False, inplace=True)
>>> s
3 beetle
1 cow
5 hippo
Name: animal, dtype: object<|endoftext|> |
a3889e2988f879d499628ff13009cdac61c9dba72bddad557cc822de0155306e | def to_array(self, fillna=None):
'Get a dense numpy array for the data.\n\n Parameters\n ----------\n fillna : str or None\n Defaults to None, which will skip null values.\n If it equals "pandas", null values are filled with NaNs.\n Non integral dtype is promoted to np.float64.\n\n Returns\n -------\n numpy.ndarray\n A numpy array representation of the elements in the Series.\n\n Notes\n -----\n If ``fillna`` is ``None``, null values are skipped. Therefore, the\n output size could be smaller.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12, 13, 14])\n >>> series\n 0 10\n 1 11\n 2 12\n 3 13\n 4 14\n dtype: int64\n >>> array = series.to_array()\n >>> array\n array([10, 11, 12, 13, 14])\n >>> type(array)\n <class \'numpy.ndarray\'>\n '
return self._column.to_array(fillna=fillna) | Get a dense numpy array for the data.
Parameters
----------
fillna : str or None
Defaults to None, which will skip null values.
If it equals "pandas", null values are filled with NaNs.
Non integral dtype is promoted to np.float64.
Returns
-------
numpy.ndarray
A numpy array representation of the elements in the Series.
Notes
-----
If ``fillna`` is ``None``, null values are skipped. Therefore, the
output size could be smaller.
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 11, 12, 13, 14])
>>> series
0 10
1 11
2 12
3 13
4 14
dtype: int64
>>> array = series.to_array()
>>> array
array([10, 11, 12, 13, 14])
>>> type(array)
<class 'numpy.ndarray'> | python/cudf/cudf/core/series.py | to_array | jdye64/cudf | 1 | python | def to_array(self, fillna=None):
'Get a dense numpy array for the data.\n\n Parameters\n ----------\n fillna : str or None\n Defaults to None, which will skip null values.\n If it equals "pandas", null values are filled with NaNs.\n Non integral dtype is promoted to np.float64.\n\n Returns\n -------\n numpy.ndarray\n A numpy array representation of the elements in the Series.\n\n Notes\n -----\n If ``fillna`` is ``None``, null values are skipped. Therefore, the\n output size could be smaller.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12, 13, 14])\n >>> series\n 0 10\n 1 11\n 2 12\n 3 13\n 4 14\n dtype: int64\n >>> array = series.to_array()\n >>> array\n array([10, 11, 12, 13, 14])\n >>> type(array)\n <class \'numpy.ndarray\'>\n '
return self._column.to_array(fillna=fillna) | def to_array(self, fillna=None):
'Get a dense numpy array for the data.\n\n Parameters\n ----------\n fillna : str or None\n Defaults to None, which will skip null values.\n If it equals "pandas", null values are filled with NaNs.\n Non integral dtype is promoted to np.float64.\n\n Returns\n -------\n numpy.ndarray\n A numpy array representation of the elements in the Series.\n\n Notes\n -----\n If ``fillna`` is ``None``, null values are skipped. Therefore, the\n output size could be smaller.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12, 13, 14])\n >>> series\n 0 10\n 1 11\n 2 12\n 3 13\n 4 14\n dtype: int64\n >>> array = series.to_array()\n >>> array\n array([10, 11, 12, 13, 14])\n >>> type(array)\n <class \'numpy.ndarray\'>\n '
return self._column.to_array(fillna=fillna)<|docstring|>Get a dense numpy array for the data.
Parameters
----------
fillna : str or None
Defaults to None, which will skip null values.
If it equals "pandas", null values are filled with NaNs.
Non integral dtype is promoted to np.float64.
Returns
-------
numpy.ndarray
A numpy array representation of the elements in the Series.
Notes
-----
If ``fillna`` is ``None``, null values are skipped. Therefore, the
output size could be smaller.
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 11, 12, 13, 14])
>>> series
0 10
1 11
2 12
3 13
4 14
dtype: int64
>>> array = series.to_array()
>>> array
array([10, 11, 12, 13, 14])
>>> type(array)
<class 'numpy.ndarray'><|endoftext|> |
9a77dab776ed31e3ea2e1b8aa12cf7040fe29bb02b2abce9f11764c5b1f17bcc | def to_pandas(self, index=True, nullable=False, **kwargs):
"\n Convert to a Pandas Series.\n\n Parameters\n ----------\n index : Boolean, Default True\n If ``index`` is ``True``, converts the index of cudf.Series\n and sets it to the pandas.Series. If ``index`` is ``False``,\n no index conversion is performed and pandas.Series will assign\n a default index.\n nullable : Boolean, Default False\n If ``nullable`` is ``True``, the resulting series will be\n having a corresponding nullable Pandas dtype. If ``nullable``\n is ``False``, the resulting series will either convert null\n values to ``np.nan`` or ``None`` depending on the dtype.\n\n Returns\n -------\n out : Pandas Series\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([-3, 2, 0])\n >>> pds = ser.to_pandas()\n >>> pds\n 0 -3\n 1 2\n 2 0\n dtype: int64\n >>> type(pds)\n <class 'pandas.core.series.Series'>\n\n ``nullable`` parameter can be used to control\n whether dtype can be Pandas Nullable or not:\n\n >>> ser = cudf.Series([10, 20, None, 30])\n >>> ser\n 0 10\n 1 20\n 2 <NA>\n 3 30\n dtype: int64\n >>> ser.to_pandas(nullable=True)\n 0 10\n 1 20\n 2 <NA>\n 3 30\n dtype: Int64\n >>> ser.to_pandas(nullable=False)\n 0 10.0\n 1 20.0\n 2 NaN\n 3 30.0\n dtype: float64\n "
if (index is True):
index = self.index.to_pandas()
s = self._column.to_pandas(index=index, nullable=nullable)
s.name = self.name
return s | Convert to a Pandas Series.
Parameters
----------
index : Boolean, Default True
If ``index`` is ``True``, converts the index of cudf.Series
and sets it to the pandas.Series. If ``index`` is ``False``,
no index conversion is performed and pandas.Series will assign
a default index.
nullable : Boolean, Default False
If ``nullable`` is ``True``, the resulting series will be
having a corresponding nullable Pandas dtype. If ``nullable``
is ``False``, the resulting series will either convert null
values to ``np.nan`` or ``None`` depending on the dtype.
Returns
-------
out : Pandas Series
Examples
--------
>>> import cudf
>>> ser = cudf.Series([-3, 2, 0])
>>> pds = ser.to_pandas()
>>> pds
0 -3
1 2
2 0
dtype: int64
>>> type(pds)
<class 'pandas.core.series.Series'>
``nullable`` parameter can be used to control
whether dtype can be Pandas Nullable or not:
>>> ser = cudf.Series([10, 20, None, 30])
>>> ser
0 10
1 20
2 <NA>
3 30
dtype: int64
>>> ser.to_pandas(nullable=True)
0 10
1 20
2 <NA>
3 30
dtype: Int64
>>> ser.to_pandas(nullable=False)
0 10.0
1 20.0
2 NaN
3 30.0
dtype: float64 | python/cudf/cudf/core/series.py | to_pandas | jdye64/cudf | 1 | python | def to_pandas(self, index=True, nullable=False, **kwargs):
"\n Convert to a Pandas Series.\n\n Parameters\n ----------\n index : Boolean, Default True\n If ``index`` is ``True``, converts the index of cudf.Series\n and sets it to the pandas.Series. If ``index`` is ``False``,\n no index conversion is performed and pandas.Series will assign\n a default index.\n nullable : Boolean, Default False\n If ``nullable`` is ``True``, the resulting series will be\n having a corresponding nullable Pandas dtype. If ``nullable``\n is ``False``, the resulting series will either convert null\n values to ``np.nan`` or ``None`` depending on the dtype.\n\n Returns\n -------\n out : Pandas Series\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([-3, 2, 0])\n >>> pds = ser.to_pandas()\n >>> pds\n 0 -3\n 1 2\n 2 0\n dtype: int64\n >>> type(pds)\n <class 'pandas.core.series.Series'>\n\n ``nullable`` parameter can be used to control\n whether dtype can be Pandas Nullable or not:\n\n >>> ser = cudf.Series([10, 20, None, 30])\n >>> ser\n 0 10\n 1 20\n 2 <NA>\n 3 30\n dtype: int64\n >>> ser.to_pandas(nullable=True)\n 0 10\n 1 20\n 2 <NA>\n 3 30\n dtype: Int64\n >>> ser.to_pandas(nullable=False)\n 0 10.0\n 1 20.0\n 2 NaN\n 3 30.0\n dtype: float64\n "
if (index is True):
index = self.index.to_pandas()
s = self._column.to_pandas(index=index, nullable=nullable)
s.name = self.name
return s | def to_pandas(self, index=True, nullable=False, **kwargs):
"\n Convert to a Pandas Series.\n\n Parameters\n ----------\n index : Boolean, Default True\n If ``index`` is ``True``, converts the index of cudf.Series\n and sets it to the pandas.Series. If ``index`` is ``False``,\n no index conversion is performed and pandas.Series will assign\n a default index.\n nullable : Boolean, Default False\n If ``nullable`` is ``True``, the resulting series will be\n having a corresponding nullable Pandas dtype. If ``nullable``\n is ``False``, the resulting series will either convert null\n values to ``np.nan`` or ``None`` depending on the dtype.\n\n Returns\n -------\n out : Pandas Series\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([-3, 2, 0])\n >>> pds = ser.to_pandas()\n >>> pds\n 0 -3\n 1 2\n 2 0\n dtype: int64\n >>> type(pds)\n <class 'pandas.core.series.Series'>\n\n ``nullable`` parameter can be used to control\n whether dtype can be Pandas Nullable or not:\n\n >>> ser = cudf.Series([10, 20, None, 30])\n >>> ser\n 0 10\n 1 20\n 2 <NA>\n 3 30\n dtype: int64\n >>> ser.to_pandas(nullable=True)\n 0 10\n 1 20\n 2 <NA>\n 3 30\n dtype: Int64\n >>> ser.to_pandas(nullable=False)\n 0 10.0\n 1 20.0\n 2 NaN\n 3 30.0\n dtype: float64\n "
if (index is True):
index = self.index.to_pandas()
s = self._column.to_pandas(index=index, nullable=nullable)
s.name = self.name
return s<|docstring|>Convert to a Pandas Series.
Parameters
----------
index : Boolean, Default True
If ``index`` is ``True``, converts the index of cudf.Series
and sets it to the pandas.Series. If ``index`` is ``False``,
no index conversion is performed and pandas.Series will assign
a default index.
nullable : Boolean, Default False
If ``nullable`` is ``True``, the resulting series will be
having a corresponding nullable Pandas dtype. If ``nullable``
is ``False``, the resulting series will either convert null
values to ``np.nan`` or ``None`` depending on the dtype.
Returns
-------
out : Pandas Series
Examples
--------
>>> import cudf
>>> ser = cudf.Series([-3, 2, 0])
>>> pds = ser.to_pandas()
>>> pds
0 -3
1 2
2 0
dtype: int64
>>> type(pds)
<class 'pandas.core.series.Series'>
``nullable`` parameter can be used to control
whether dtype can be Pandas Nullable or not:
>>> ser = cudf.Series([10, 20, None, 30])
>>> ser
0 10
1 20
2 <NA>
3 30
dtype: int64
>>> ser.to_pandas(nullable=True)
0 10
1 20
2 <NA>
3 30
dtype: Int64
>>> ser.to_pandas(nullable=False)
0 10.0
1 20.0
2 NaN
3 30.0
dtype: float64<|endoftext|> |
ae34d50ffeeb8467d71705176e51cfc07516bc267cd0ef7ea3e19e715efb9c52 | @property
def data(self):
'The gpu buffer for the data\n\n Returns\n -------\n out : The GPU buffer of the Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n dtype: int64\n >>> series.data\n <cudf.core.buffer.Buffer object at 0x7f23c192d110>\n >>> series.data.to_host_array()\n array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,\n 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)\n '
return self._column.data | The gpu buffer for the data
Returns
-------
out : The GPU buffer of the Series.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4])
>>> series
0 1
1 2
2 3
3 4
dtype: int64
>>> series.data
<cudf.core.buffer.Buffer object at 0x7f23c192d110>
>>> series.data.to_host_array()
array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0, 0, 4, 0, 0, 0, 0, 0, 0, 0], dtype=uint8) | python/cudf/cudf/core/series.py | data | jdye64/cudf | 1 | python | @property
def data(self):
'The gpu buffer for the data\n\n Returns\n -------\n out : The GPU buffer of the Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n dtype: int64\n >>> series.data\n <cudf.core.buffer.Buffer object at 0x7f23c192d110>\n >>> series.data.to_host_array()\n array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,\n 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)\n '
return self._column.data | @property
def data(self):
'The gpu buffer for the data\n\n Returns\n -------\n out : The GPU buffer of the Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n dtype: int64\n >>> series.data\n <cudf.core.buffer.Buffer object at 0x7f23c192d110>\n >>> series.data.to_host_array()\n array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,\n 0, 0, 4, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)\n '
return self._column.data<|docstring|>The gpu buffer for the data
Returns
-------
out : The GPU buffer of the Series.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4])
>>> series
0 1
1 2
2 3
3 4
dtype: int64
>>> series.data
<cudf.core.buffer.Buffer object at 0x7f23c192d110>
>>> series.data.to_host_array()
array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0, 0, 4, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)<|endoftext|> |
10bbc595d54f36c55759b066cc0419d1005a283afbc21f267532df45185d43ac | @property
def index(self):
'The index object\n '
return self._index | The index object | python/cudf/cudf/core/series.py | index | jdye64/cudf | 1 | python | @property
def index(self):
'\n '
return self._index | @property
def index(self):
'\n '
return self._index<|docstring|>The index object<|endoftext|> |
1449db9fa54ec8d2a36d6e45f63d1c4057dba9c5681b72860546dd7558717414 | @property
def loc(self):
"\n Select values by label.\n\n See also\n --------\n cudf.DataFrame.loc\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12], index=['a', 'b', 'c'])\n >>> series\n a 10\n b 11\n c 12\n dtype: int64\n >>> series.loc['b']\n 11\n "
return _SeriesLocIndexer(self) | Select values by label.
See also
--------
cudf.DataFrame.loc
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 11, 12], index=['a', 'b', 'c'])
>>> series
a 10
b 11
c 12
dtype: int64
>>> series.loc['b']
11 | python/cudf/cudf/core/series.py | loc | jdye64/cudf | 1 | python | @property
def loc(self):
"\n Select values by label.\n\n See also\n --------\n cudf.DataFrame.loc\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12], index=['a', 'b', 'c'])\n >>> series\n a 10\n b 11\n c 12\n dtype: int64\n >>> series.loc['b']\n 11\n "
return _SeriesLocIndexer(self) | @property
def loc(self):
"\n Select values by label.\n\n See also\n --------\n cudf.DataFrame.loc\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12], index=['a', 'b', 'c'])\n >>> series\n a 10\n b 11\n c 12\n dtype: int64\n >>> series.loc['b']\n 11\n "
return _SeriesLocIndexer(self)<|docstring|>Select values by label.
See also
--------
cudf.DataFrame.loc
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 11, 12], index=['a', 'b', 'c'])
>>> series
a 10
b 11
c 12
dtype: int64
>>> series.loc['b']
11<|endoftext|> |
b554ac97ce6b4dac970d63a87328cdb76a0afc534ae4c4d20082369a5df88384 | @property
def iloc(self):
'\n Select values by position.\n\n See also\n --------\n cudf.DataFrame.iloc\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([10, 20, 30])\n >>> s\n 0 10\n 1 20\n 2 30\n dtype: int64\n >>> s.iloc[2]\n 30\n '
return _SeriesIlocIndexer(self) | Select values by position.
See also
--------
cudf.DataFrame.iloc
Examples
--------
>>> import cudf
>>> s = cudf.Series([10, 20, 30])
>>> s
0 10
1 20
2 30
dtype: int64
>>> s.iloc[2]
30 | python/cudf/cudf/core/series.py | iloc | jdye64/cudf | 1 | python | @property
def iloc(self):
'\n Select values by position.\n\n See also\n --------\n cudf.DataFrame.iloc\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([10, 20, 30])\n >>> s\n 0 10\n 1 20\n 2 30\n dtype: int64\n >>> s.iloc[2]\n 30\n '
return _SeriesIlocIndexer(self) | @property
def iloc(self):
'\n Select values by position.\n\n See also\n --------\n cudf.DataFrame.iloc\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([10, 20, 30])\n >>> s\n 0 10\n 1 20\n 2 30\n dtype: int64\n >>> s.iloc[2]\n 30\n '
return _SeriesIlocIndexer(self)<|docstring|>Select values by position.
See also
--------
cudf.DataFrame.iloc
Examples
--------
>>> import cudf
>>> s = cudf.Series([10, 20, 30])
>>> s
0 10
1 20
2 30
dtype: int64
>>> s.iloc[2]
30<|endoftext|> |
87834f3a3d2c7369e4bed96dcbc94c8881a0bab3733ec1212e7227eea641f518 | @property
def nullmask(self):
'The gpu buffer for the null-mask\n '
return cudf.Series(self._column.nullmask) | The gpu buffer for the null-mask | python/cudf/cudf/core/series.py | nullmask | jdye64/cudf | 1 | python | @property
def nullmask(self):
'\n '
return cudf.Series(self._column.nullmask) | @property
def nullmask(self):
'\n '
return cudf.Series(self._column.nullmask)<|docstring|>The gpu buffer for the null-mask<|endoftext|> |
293eba58cb31632d4acce0720f3ddc6c5fe374d4fa6b96ed1064248616b14123 | def as_mask(self):
'Convert booleans to bitmask\n\n Returns\n -------\n device array\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([True, False, True])\n >>> s.as_mask()\n <cudf.core.buffer.Buffer object at 0x7f23c3eed0d0>\n >>> s.as_mask().to_host_array()\n array([ 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 181, 164,\n 188, 1, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,\n 127, 253, 214, 62, 241, 1, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n dtype=uint8)\n '
if (not is_bool_dtype(self.dtype)):
raise TypeError(f'Series must of boolean dtype, found: {self.dtype}')
return self._column.as_mask() | Convert booleans to bitmask
Returns
-------
device array
Examples
--------
>>> import cudf
>>> s = cudf.Series([True, False, True])
>>> s.as_mask()
<cudf.core.buffer.Buffer object at 0x7f23c3eed0d0>
>>> s.as_mask().to_host_array()
array([ 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 181, 164,
188, 1, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,
127, 253, 214, 62, 241, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
dtype=uint8) | python/cudf/cudf/core/series.py | as_mask | jdye64/cudf | 1 | python | def as_mask(self):
'Convert booleans to bitmask\n\n Returns\n -------\n device array\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([True, False, True])\n >>> s.as_mask()\n <cudf.core.buffer.Buffer object at 0x7f23c3eed0d0>\n >>> s.as_mask().to_host_array()\n array([ 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 181, 164,\n 188, 1, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,\n 127, 253, 214, 62, 241, 1, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n dtype=uint8)\n '
if (not is_bool_dtype(self.dtype)):
raise TypeError(f'Series must of boolean dtype, found: {self.dtype}')
return self._column.as_mask() | def as_mask(self):
'Convert booleans to bitmask\n\n Returns\n -------\n device array\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([True, False, True])\n >>> s.as_mask()\n <cudf.core.buffer.Buffer object at 0x7f23c3eed0d0>\n >>> s.as_mask().to_host_array()\n array([ 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 181, 164,\n 188, 1, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,\n 127, 253, 214, 62, 241, 1, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n dtype=uint8)\n '
if (not is_bool_dtype(self.dtype)):
raise TypeError(f'Series must of boolean dtype, found: {self.dtype}')
return self._column.as_mask()<|docstring|>Convert booleans to bitmask
Returns
-------
device array
Examples
--------
>>> import cudf
>>> s = cudf.Series([True, False, True])
>>> s.as_mask()
<cudf.core.buffer.Buffer object at 0x7f23c3eed0d0>
>>> s.as_mask().to_host_array()
array([ 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 181, 164,
188, 1, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,
127, 253, 214, 62, 241, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
dtype=uint8)<|endoftext|> |
5daa8a3b98fa02ce3dab21e0e0fa7310debd8af71cfd7ba8957902cd7026a4b3 | def astype(self, dtype, copy=False, errors='raise'):
"\n Cast the Series to the given dtype\n\n Parameters\n ----------\n\n dtype : data type, or dict of column name -> data type\n Use a numpy.dtype or Python type to cast Series object to\n the same type. Alternatively, use {col: dtype, ...}, where col is a\n series name and dtype is a numpy.dtype or Python type to cast to.\n copy : bool, default False\n Return a deep-copy when ``copy=True``. Note by default\n ``copy=False`` setting is used and hence changes to\n values then may propagate to other cudf objects.\n errors : {'raise', 'ignore', 'warn'}, default 'raise'\n Control raising of exceptions on invalid data for provided dtype.\n\n - ``raise`` : allow exceptions to be raised\n - ``ignore`` : suppress exceptions. On error return original\n object.\n - ``warn`` : prints last exceptions as warnings and\n return original object.\n\n Returns\n -------\n out : Series\n Returns ``self.copy(deep=copy)`` if ``dtype`` is the same\n as ``self.dtype``.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2], dtype='int32')\n >>> series\n 0 1\n 1 2\n dtype: int32\n >>> series.astype('int64')\n 0 1\n 1 2\n dtype: int64\n\n Convert to categorical type:\n\n >>> series.astype('category')\n 0 1\n 1 2\n dtype: category\n Categories (2, int64): [1, 2]\n\n Convert to ordered categorical type with custom ordering:\n\n >>> cat_dtype = cudf.CategoricalDtype(categories=[2, 1], ordered=True)\n >>> series.astype(cat_dtype)\n 0 1\n 1 2\n dtype: category\n Categories (2, int64): [2 < 1]\n\n Note that using ``copy=False`` (enabled by default)\n and changing data on a new Series will\n propagate changes:\n\n >>> s1 = cudf.Series([1, 2])\n >>> s1\n 0 1\n 1 2\n dtype: int64\n >>> s2 = s1.astype('int64', copy=False)\n >>> s2[0] = 10\n >>> s1\n 0 10\n 1 2\n dtype: int64\n "
if (errors not in ('ignore', 'raise', 'warn')):
raise ValueError('invalid error value specified')
if is_dict_like(dtype):
if ((len(dtype) > 1) or (self.name not in dtype)):
raise KeyError('Only the Series name can be used for the key in Series dtype mappings.')
dtype = dtype[self.name]
if is_dtype_equal(dtype, self.dtype):
return self.copy(deep=copy)
try:
data = self._column.astype(dtype)
return self._from_data({self.name: (data.copy(deep=True) if copy else data)}, index=self._index)
except Exception as e:
if (errors == 'raise'):
raise e
elif (errors == 'warn'):
import traceback
tb = traceback.format_exc()
warnings.warn(tb)
elif (errors == 'ignore'):
pass
return self | Cast the Series to the given dtype
Parameters
----------
dtype : data type, or dict of column name -> data type
Use a numpy.dtype or Python type to cast Series object to
the same type. Alternatively, use {col: dtype, ...}, where col is a
series name and dtype is a numpy.dtype or Python type to cast to.
copy : bool, default False
Return a deep-copy when ``copy=True``. Note by default
``copy=False`` setting is used and hence changes to
values then may propagate to other cudf objects.
errors : {'raise', 'ignore', 'warn'}, default 'raise'
Control raising of exceptions on invalid data for provided dtype.
- ``raise`` : allow exceptions to be raised
- ``ignore`` : suppress exceptions. On error return original
object.
- ``warn`` : prints last exceptions as warnings and
return original object.
Returns
-------
out : Series
Returns ``self.copy(deep=copy)`` if ``dtype`` is the same
as ``self.dtype``.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2], dtype='int32')
>>> series
0 1
1 2
dtype: int32
>>> series.astype('int64')
0 1
1 2
dtype: int64
Convert to categorical type:
>>> series.astype('category')
0 1
1 2
dtype: category
Categories (2, int64): [1, 2]
Convert to ordered categorical type with custom ordering:
>>> cat_dtype = cudf.CategoricalDtype(categories=[2, 1], ordered=True)
>>> series.astype(cat_dtype)
0 1
1 2
dtype: category
Categories (2, int64): [2 < 1]
Note that using ``copy=False`` (enabled by default)
and changing data on a new Series will
propagate changes:
>>> s1 = cudf.Series([1, 2])
>>> s1
0 1
1 2
dtype: int64
>>> s2 = s1.astype('int64', copy=False)
>>> s2[0] = 10
>>> s1
0 10
1 2
dtype: int64 | python/cudf/cudf/core/series.py | astype | jdye64/cudf | 1 | python | def astype(self, dtype, copy=False, errors='raise'):
"\n Cast the Series to the given dtype\n\n Parameters\n ----------\n\n dtype : data type, or dict of column name -> data type\n Use a numpy.dtype or Python type to cast Series object to\n the same type. Alternatively, use {col: dtype, ...}, where col is a\n series name and dtype is a numpy.dtype or Python type to cast to.\n copy : bool, default False\n Return a deep-copy when ``copy=True``. Note by default\n ``copy=False`` setting is used and hence changes to\n values then may propagate to other cudf objects.\n errors : {'raise', 'ignore', 'warn'}, default 'raise'\n Control raising of exceptions on invalid data for provided dtype.\n\n - ``raise`` : allow exceptions to be raised\n - ``ignore`` : suppress exceptions. On error return original\n object.\n - ``warn`` : prints last exceptions as warnings and\n return original object.\n\n Returns\n -------\n out : Series\n Returns ``self.copy(deep=copy)`` if ``dtype`` is the same\n as ``self.dtype``.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2], dtype='int32')\n >>> series\n 0 1\n 1 2\n dtype: int32\n >>> series.astype('int64')\n 0 1\n 1 2\n dtype: int64\n\n Convert to categorical type:\n\n >>> series.astype('category')\n 0 1\n 1 2\n dtype: category\n Categories (2, int64): [1, 2]\n\n Convert to ordered categorical type with custom ordering:\n\n >>> cat_dtype = cudf.CategoricalDtype(categories=[2, 1], ordered=True)\n >>> series.astype(cat_dtype)\n 0 1\n 1 2\n dtype: category\n Categories (2, int64): [2 < 1]\n\n Note that using ``copy=False`` (enabled by default)\n and changing data on a new Series will\n propagate changes:\n\n >>> s1 = cudf.Series([1, 2])\n >>> s1\n 0 1\n 1 2\n dtype: int64\n >>> s2 = s1.astype('int64', copy=False)\n >>> s2[0] = 10\n >>> s1\n 0 10\n 1 2\n dtype: int64\n "
if (errors not in ('ignore', 'raise', 'warn')):
raise ValueError('invalid error value specified')
if is_dict_like(dtype):
if ((len(dtype) > 1) or (self.name not in dtype)):
raise KeyError('Only the Series name can be used for the key in Series dtype mappings.')
dtype = dtype[self.name]
if is_dtype_equal(dtype, self.dtype):
return self.copy(deep=copy)
try:
data = self._column.astype(dtype)
return self._from_data({self.name: (data.copy(deep=True) if copy else data)}, index=self._index)
except Exception as e:
if (errors == 'raise'):
raise e
elif (errors == 'warn'):
import traceback
tb = traceback.format_exc()
warnings.warn(tb)
elif (errors == 'ignore'):
pass
return self | def astype(self, dtype, copy=False, errors='raise'):
"\n Cast the Series to the given dtype\n\n Parameters\n ----------\n\n dtype : data type, or dict of column name -> data type\n Use a numpy.dtype or Python type to cast Series object to\n the same type. Alternatively, use {col: dtype, ...}, where col is a\n series name and dtype is a numpy.dtype or Python type to cast to.\n copy : bool, default False\n Return a deep-copy when ``copy=True``. Note by default\n ``copy=False`` setting is used and hence changes to\n values then may propagate to other cudf objects.\n errors : {'raise', 'ignore', 'warn'}, default 'raise'\n Control raising of exceptions on invalid data for provided dtype.\n\n - ``raise`` : allow exceptions to be raised\n - ``ignore`` : suppress exceptions. On error return original\n object.\n - ``warn`` : prints last exceptions as warnings and\n return original object.\n\n Returns\n -------\n out : Series\n Returns ``self.copy(deep=copy)`` if ``dtype`` is the same\n as ``self.dtype``.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2], dtype='int32')\n >>> series\n 0 1\n 1 2\n dtype: int32\n >>> series.astype('int64')\n 0 1\n 1 2\n dtype: int64\n\n Convert to categorical type:\n\n >>> series.astype('category')\n 0 1\n 1 2\n dtype: category\n Categories (2, int64): [1, 2]\n\n Convert to ordered categorical type with custom ordering:\n\n >>> cat_dtype = cudf.CategoricalDtype(categories=[2, 1], ordered=True)\n >>> series.astype(cat_dtype)\n 0 1\n 1 2\n dtype: category\n Categories (2, int64): [2 < 1]\n\n Note that using ``copy=False`` (enabled by default)\n and changing data on a new Series will\n propagate changes:\n\n >>> s1 = cudf.Series([1, 2])\n >>> s1\n 0 1\n 1 2\n dtype: int64\n >>> s2 = s1.astype('int64', copy=False)\n >>> s2[0] = 10\n >>> s1\n 0 10\n 1 2\n dtype: int64\n "
if (errors not in ('ignore', 'raise', 'warn')):
raise ValueError('invalid error value specified')
if is_dict_like(dtype):
if ((len(dtype) > 1) or (self.name not in dtype)):
raise KeyError('Only the Series name can be used for the key in Series dtype mappings.')
dtype = dtype[self.name]
if is_dtype_equal(dtype, self.dtype):
return self.copy(deep=copy)
try:
data = self._column.astype(dtype)
return self._from_data({self.name: (data.copy(deep=True) if copy else data)}, index=self._index)
except Exception as e:
if (errors == 'raise'):
raise e
elif (errors == 'warn'):
import traceback
tb = traceback.format_exc()
warnings.warn(tb)
elif (errors == 'ignore'):
pass
return self<|docstring|>Cast the Series to the given dtype
Parameters
----------
dtype : data type, or dict of column name -> data type
Use a numpy.dtype or Python type to cast Series object to
the same type. Alternatively, use {col: dtype, ...}, where col is a
series name and dtype is a numpy.dtype or Python type to cast to.
copy : bool, default False
Return a deep-copy when ``copy=True``. Note by default
``copy=False`` setting is used and hence changes to
values then may propagate to other cudf objects.
errors : {'raise', 'ignore', 'warn'}, default 'raise'
Control raising of exceptions on invalid data for provided dtype.
- ``raise`` : allow exceptions to be raised
- ``ignore`` : suppress exceptions. On error return original
object.
- ``warn`` : prints last exceptions as warnings and
return original object.
Returns
-------
out : Series
Returns ``self.copy(deep=copy)`` if ``dtype`` is the same
as ``self.dtype``.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2], dtype='int32')
>>> series
0 1
1 2
dtype: int32
>>> series.astype('int64')
0 1
1 2
dtype: int64
Convert to categorical type:
>>> series.astype('category')
0 1
1 2
dtype: category
Categories (2, int64): [1, 2]
Convert to ordered categorical type with custom ordering:
>>> cat_dtype = cudf.CategoricalDtype(categories=[2, 1], ordered=True)
>>> series.astype(cat_dtype)
0 1
1 2
dtype: category
Categories (2, int64): [2 < 1]
Note that using ``copy=False`` (enabled by default)
and changing data on a new Series will
propagate changes:
>>> s1 = cudf.Series([1, 2])
>>> s1
0 1
1 2
dtype: int64
>>> s2 = s1.astype('int64', copy=False)
>>> s2[0] = 10
>>> s1
0 10
1 2
dtype: int64<|endoftext|> |
f6df30b063274cf9aa9f2ad16e5fd4ba892c93eaa871af8c2edba149d3d89529 | def argsort(self, ascending=True, na_position='last'):
'Returns a Series of int64 index that will sort the series.\n\n Uses Thrust sort.\n\n Returns\n -------\n result: Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([3, 1, 2])\n >>> s\n 0 3\n 1 1\n 2 2\n dtype: int64\n >>> s.argsort()\n 0 1\n 1 2\n 2 0\n dtype: int32\n >>> s[s.argsort()]\n 1 1\n 2 2\n 0 3\n dtype: int64\n '
return self._sort(ascending=ascending, na_position=na_position)[1] | Returns a Series of int64 index that will sort the series.
Uses Thrust sort.
Returns
-------
result: Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([3, 1, 2])
>>> s
0 3
1 1
2 2
dtype: int64
>>> s.argsort()
0 1
1 2
2 0
dtype: int32
>>> s[s.argsort()]
1 1
2 2
0 3
dtype: int64 | python/cudf/cudf/core/series.py | argsort | jdye64/cudf | 1 | python | def argsort(self, ascending=True, na_position='last'):
'Returns a Series of int64 index that will sort the series.\n\n Uses Thrust sort.\n\n Returns\n -------\n result: Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([3, 1, 2])\n >>> s\n 0 3\n 1 1\n 2 2\n dtype: int64\n >>> s.argsort()\n 0 1\n 1 2\n 2 0\n dtype: int32\n >>> s[s.argsort()]\n 1 1\n 2 2\n 0 3\n dtype: int64\n '
return self._sort(ascending=ascending, na_position=na_position)[1] | def argsort(self, ascending=True, na_position='last'):
'Returns a Series of int64 index that will sort the series.\n\n Uses Thrust sort.\n\n Returns\n -------\n result: Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([3, 1, 2])\n >>> s\n 0 3\n 1 1\n 2 2\n dtype: int64\n >>> s.argsort()\n 0 1\n 1 2\n 2 0\n dtype: int32\n >>> s[s.argsort()]\n 1 1\n 2 2\n 0 3\n dtype: int64\n '
return self._sort(ascending=ascending, na_position=na_position)[1]<|docstring|>Returns a Series of int64 index that will sort the series.
Uses Thrust sort.
Returns
-------
result: Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([3, 1, 2])
>>> s
0 3
1 1
2 2
dtype: int64
>>> s.argsort()
0 1
1 2
2 0
dtype: int32
>>> s[s.argsort()]
1 1
2 2
0 3
dtype: int64<|endoftext|> |
05d11965ca35d72cb65ab6f155bae0e1febd2a8f05e2eb30b4540989e7b81259 | def sort_index(self, ascending=True):
"\n Sort by the index.\n\n Parameters\n ----------\n ascending : bool, default True\n Sort ascending vs. descending.\n\n Returns\n -------\n Series\n The original Series sorted by the labels.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series(['a', 'b', 'c', 'd'], index=[3, 2, 1, 4])\n >>> series\n 3 a\n 2 b\n 1 c\n 4 d\n dtype: object\n >>> series.sort_index()\n 1 c\n 2 b\n 3 a\n 4 d\n dtype: object\n\n Sort Descending\n\n >>> series.sort_index(ascending=False)\n 4 d\n 3 a\n 2 b\n 1 c\n dtype: object\n "
inds = self.index.argsort(ascending=ascending)
return self.take(inds) | Sort by the index.
Parameters
----------
ascending : bool, default True
Sort ascending vs. descending.
Returns
-------
Series
The original Series sorted by the labels.
Examples
--------
>>> import cudf
>>> series = cudf.Series(['a', 'b', 'c', 'd'], index=[3, 2, 1, 4])
>>> series
3 a
2 b
1 c
4 d
dtype: object
>>> series.sort_index()
1 c
2 b
3 a
4 d
dtype: object
Sort Descending
>>> series.sort_index(ascending=False)
4 d
3 a
2 b
1 c
dtype: object | python/cudf/cudf/core/series.py | sort_index | jdye64/cudf | 1 | python | def sort_index(self, ascending=True):
"\n Sort by the index.\n\n Parameters\n ----------\n ascending : bool, default True\n Sort ascending vs. descending.\n\n Returns\n -------\n Series\n The original Series sorted by the labels.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series(['a', 'b', 'c', 'd'], index=[3, 2, 1, 4])\n >>> series\n 3 a\n 2 b\n 1 c\n 4 d\n dtype: object\n >>> series.sort_index()\n 1 c\n 2 b\n 3 a\n 4 d\n dtype: object\n\n Sort Descending\n\n >>> series.sort_index(ascending=False)\n 4 d\n 3 a\n 2 b\n 1 c\n dtype: object\n "
inds = self.index.argsort(ascending=ascending)
return self.take(inds) | def sort_index(self, ascending=True):
"\n Sort by the index.\n\n Parameters\n ----------\n ascending : bool, default True\n Sort ascending vs. descending.\n\n Returns\n -------\n Series\n The original Series sorted by the labels.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series(['a', 'b', 'c', 'd'], index=[3, 2, 1, 4])\n >>> series\n 3 a\n 2 b\n 1 c\n 4 d\n dtype: object\n >>> series.sort_index()\n 1 c\n 2 b\n 3 a\n 4 d\n dtype: object\n\n Sort Descending\n\n >>> series.sort_index(ascending=False)\n 4 d\n 3 a\n 2 b\n 1 c\n dtype: object\n "
inds = self.index.argsort(ascending=ascending)
return self.take(inds)<|docstring|>Sort by the index.
Parameters
----------
ascending : bool, default True
Sort ascending vs. descending.
Returns
-------
Series
The original Series sorted by the labels.
Examples
--------
>>> import cudf
>>> series = cudf.Series(['a', 'b', 'c', 'd'], index=[3, 2, 1, 4])
>>> series
3 a
2 b
1 c
4 d
dtype: object
>>> series.sort_index()
1 c
2 b
3 a
4 d
dtype: object
Sort Descending
>>> series.sort_index(ascending=False)
4 d
3 a
2 b
1 c
dtype: object<|endoftext|> |
4815a2fa3badc7141f4483ff6753661f07c90faa26d5a666befc9195d664b54a | def sort_values(self, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last', ignore_index=False):
"\n Sort by the values.\n\n Sort a Series in ascending or descending order by some criterion.\n\n Parameters\n ----------\n ascending : bool, default True\n If True, sort values in ascending order, otherwise descending.\n na_position : {‘first’, ‘last’}, default ‘last’\n 'first' puts nulls at the beginning, 'last' puts nulls at the end.\n ignore_index : bool, default False\n If True, index will not be sorted.\n\n Returns\n -------\n sorted_obj : cuDF Series\n\n Notes\n -----\n Difference from pandas:\n * Not supporting: `inplace`, `kind`\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 5, 2, 4, 3])\n >>> s.sort_values()\n 0 1\n 2 2\n 4 3\n 3 4\n 1 5\n dtype: int64\n "
if inplace:
raise NotImplementedError('`inplace` not currently implemented.')
if (kind != 'quicksort'):
raise NotImplementedError('`kind` not currently implemented.')
if (axis != 0):
raise NotImplementedError('`axis` not currently implemented.')
if (len(self) == 0):
return self
(vals, inds) = self._sort(ascending=ascending, na_position=na_position)
if (not ignore_index):
index = self.index.take(inds)
else:
index = self.index
return vals.set_index(index) | Sort by the values.
Sort a Series in ascending or descending order by some criterion.
Parameters
----------
ascending : bool, default True
If True, sort values in ascending order, otherwise descending.
na_position : {‘first’, ‘last’}, default ‘last’
'first' puts nulls at the beginning, 'last' puts nulls at the end.
ignore_index : bool, default False
If True, index will not be sorted.
Returns
-------
sorted_obj : cuDF Series
Notes
-----
Difference from pandas:
* Not supporting: `inplace`, `kind`
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 5, 2, 4, 3])
>>> s.sort_values()
0 1
2 2
4 3
3 4
1 5
dtype: int64 | python/cudf/cudf/core/series.py | sort_values | jdye64/cudf | 1 | python | def sort_values(self, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last', ignore_index=False):
"\n Sort by the values.\n\n Sort a Series in ascending or descending order by some criterion.\n\n Parameters\n ----------\n ascending : bool, default True\n If True, sort values in ascending order, otherwise descending.\n na_position : {‘first’, ‘last’}, default ‘last’\n 'first' puts nulls at the beginning, 'last' puts nulls at the end.\n ignore_index : bool, default False\n If True, index will not be sorted.\n\n Returns\n -------\n sorted_obj : cuDF Series\n\n Notes\n -----\n Difference from pandas:\n * Not supporting: `inplace`, `kind`\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 5, 2, 4, 3])\n >>> s.sort_values()\n 0 1\n 2 2\n 4 3\n 3 4\n 1 5\n dtype: int64\n "
if inplace:
raise NotImplementedError('`inplace` not currently implemented.')
if (kind != 'quicksort'):
raise NotImplementedError('`kind` not currently implemented.')
if (axis != 0):
raise NotImplementedError('`axis` not currently implemented.')
if (len(self) == 0):
return self
(vals, inds) = self._sort(ascending=ascending, na_position=na_position)
if (not ignore_index):
index = self.index.take(inds)
else:
index = self.index
return vals.set_index(index) | def sort_values(self, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last', ignore_index=False):
"\n Sort by the values.\n\n Sort a Series in ascending or descending order by some criterion.\n\n Parameters\n ----------\n ascending : bool, default True\n If True, sort values in ascending order, otherwise descending.\n na_position : {‘first’, ‘last’}, default ‘last’\n 'first' puts nulls at the beginning, 'last' puts nulls at the end.\n ignore_index : bool, default False\n If True, index will not be sorted.\n\n Returns\n -------\n sorted_obj : cuDF Series\n\n Notes\n -----\n Difference from pandas:\n * Not supporting: `inplace`, `kind`\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 5, 2, 4, 3])\n >>> s.sort_values()\n 0 1\n 2 2\n 4 3\n 3 4\n 1 5\n dtype: int64\n "
if inplace:
raise NotImplementedError('`inplace` not currently implemented.')
if (kind != 'quicksort'):
raise NotImplementedError('`kind` not currently implemented.')
if (axis != 0):
raise NotImplementedError('`axis` not currently implemented.')
if (len(self) == 0):
return self
(vals, inds) = self._sort(ascending=ascending, na_position=na_position)
if (not ignore_index):
index = self.index.take(inds)
else:
index = self.index
return vals.set_index(index)<|docstring|>Sort by the values.
Sort a Series in ascending or descending order by some criterion.
Parameters
----------
ascending : bool, default True
If True, sort values in ascending order, otherwise descending.
na_position : {‘first’, ‘last’}, default ‘last’
'first' puts nulls at the beginning, 'last' puts nulls at the end.
ignore_index : bool, default False
If True, index will not be sorted.
Returns
-------
sorted_obj : cuDF Series
Notes
-----
Difference from pandas:
* Not supporting: `inplace`, `kind`
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 5, 2, 4, 3])
>>> s.sort_values()
0 1
2 2
4 3
3 4
1 5
dtype: int64<|endoftext|> |
6263f8efec834edc80145a99d8fea119873b7a913926643572c52c4e8935d60e | def nlargest(self, n=5, keep='first'):
'Returns a new Series of the *n* largest element.\n\n Parameters\n ----------\n n : int, default 5\n Return this many descending sorted values.\n keep : {\'first\', \'last\'}, default \'first\'\n When there are duplicate values that cannot all fit in a\n Series of `n` elements:\n\n - ``first`` : return the first `n` occurrences in order\n of appearance.\n - ``last`` : return the last `n` occurrences in reverse\n order of appearance.\n\n Returns\n -------\n Series\n The `n` largest values in the Series, sorted in decreasing order.\n\n Examples\n --------\n >>> import cudf\n >>> countries_population = {"Italy": 59000000, "France": 65000000,\n ... "Malta": 434000, "Maldives": 434000,\n ... "Brunei": 434000, "Iceland": 337000,\n ... "Nauru": 11300, "Tuvalu": 11300,\n ... "Anguilla": 11300, "Montserrat": 5200}\n >>> series = cudf.Series(countries_population)\n >>> series\n Italy 59000000\n France 65000000\n Malta 434000\n Maldives 434000\n Brunei 434000\n Iceland 337000\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Montserrat 5200\n dtype: int64\n >>> series.nlargest()\n France 65000000\n Italy 59000000\n Malta 434000\n Maldives 434000\n Brunei 434000\n dtype: int64\n >>> series.nlargest(3)\n France 65000000\n Italy 59000000\n Malta 434000\n dtype: int64\n >>> series.nlargest(3, keep=\'last\')\n France 65000000\n Italy 59000000\n Brunei 434000\n dtype: int64\n '
return self._n_largest_or_smallest(n=n, keep=keep, largest=True) | Returns a new Series of the *n* largest element.
Parameters
----------
n : int, default 5
Return this many descending sorted values.
keep : {'first', 'last'}, default 'first'
When there are duplicate values that cannot all fit in a
Series of `n` elements:
- ``first`` : return the first `n` occurrences in order
of appearance.
- ``last`` : return the last `n` occurrences in reverse
order of appearance.
Returns
-------
Series
The `n` largest values in the Series, sorted in decreasing order.
Examples
--------
>>> import cudf
>>> countries_population = {"Italy": 59000000, "France": 65000000,
... "Malta": 434000, "Maldives": 434000,
... "Brunei": 434000, "Iceland": 337000,
... "Nauru": 11300, "Tuvalu": 11300,
... "Anguilla": 11300, "Montserrat": 5200}
>>> series = cudf.Series(countries_population)
>>> series
Italy 59000000
France 65000000
Malta 434000
Maldives 434000
Brunei 434000
Iceland 337000
Nauru 11300
Tuvalu 11300
Anguilla 11300
Montserrat 5200
dtype: int64
>>> series.nlargest()
France 65000000
Italy 59000000
Malta 434000
Maldives 434000
Brunei 434000
dtype: int64
>>> series.nlargest(3)
France 65000000
Italy 59000000
Malta 434000
dtype: int64
>>> series.nlargest(3, keep='last')
France 65000000
Italy 59000000
Brunei 434000
dtype: int64 | python/cudf/cudf/core/series.py | nlargest | jdye64/cudf | 1 | python | def nlargest(self, n=5, keep='first'):
'Returns a new Series of the *n* largest element.\n\n Parameters\n ----------\n n : int, default 5\n Return this many descending sorted values.\n keep : {\'first\', \'last\'}, default \'first\'\n When there are duplicate values that cannot all fit in a\n Series of `n` elements:\n\n - ``first`` : return the first `n` occurrences in order\n of appearance.\n - ``last`` : return the last `n` occurrences in reverse\n order of appearance.\n\n Returns\n -------\n Series\n The `n` largest values in the Series, sorted in decreasing order.\n\n Examples\n --------\n >>> import cudf\n >>> countries_population = {"Italy": 59000000, "France": 65000000,\n ... "Malta": 434000, "Maldives": 434000,\n ... "Brunei": 434000, "Iceland": 337000,\n ... "Nauru": 11300, "Tuvalu": 11300,\n ... "Anguilla": 11300, "Montserrat": 5200}\n >>> series = cudf.Series(countries_population)\n >>> series\n Italy 59000000\n France 65000000\n Malta 434000\n Maldives 434000\n Brunei 434000\n Iceland 337000\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Montserrat 5200\n dtype: int64\n >>> series.nlargest()\n France 65000000\n Italy 59000000\n Malta 434000\n Maldives 434000\n Brunei 434000\n dtype: int64\n >>> series.nlargest(3)\n France 65000000\n Italy 59000000\n Malta 434000\n dtype: int64\n >>> series.nlargest(3, keep=\'last\')\n France 65000000\n Italy 59000000\n Brunei 434000\n dtype: int64\n '
return self._n_largest_or_smallest(n=n, keep=keep, largest=True) | def nlargest(self, n=5, keep='first'):
'Returns a new Series of the *n* largest element.\n\n Parameters\n ----------\n n : int, default 5\n Return this many descending sorted values.\n keep : {\'first\', \'last\'}, default \'first\'\n When there are duplicate values that cannot all fit in a\n Series of `n` elements:\n\n - ``first`` : return the first `n` occurrences in order\n of appearance.\n - ``last`` : return the last `n` occurrences in reverse\n order of appearance.\n\n Returns\n -------\n Series\n The `n` largest values in the Series, sorted in decreasing order.\n\n Examples\n --------\n >>> import cudf\n >>> countries_population = {"Italy": 59000000, "France": 65000000,\n ... "Malta": 434000, "Maldives": 434000,\n ... "Brunei": 434000, "Iceland": 337000,\n ... "Nauru": 11300, "Tuvalu": 11300,\n ... "Anguilla": 11300, "Montserrat": 5200}\n >>> series = cudf.Series(countries_population)\n >>> series\n Italy 59000000\n France 65000000\n Malta 434000\n Maldives 434000\n Brunei 434000\n Iceland 337000\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Montserrat 5200\n dtype: int64\n >>> series.nlargest()\n France 65000000\n Italy 59000000\n Malta 434000\n Maldives 434000\n Brunei 434000\n dtype: int64\n >>> series.nlargest(3)\n France 65000000\n Italy 59000000\n Malta 434000\n dtype: int64\n >>> series.nlargest(3, keep=\'last\')\n France 65000000\n Italy 59000000\n Brunei 434000\n dtype: int64\n '
return self._n_largest_or_smallest(n=n, keep=keep, largest=True)<|docstring|>Returns a new Series of the *n* largest element.
Parameters
----------
n : int, default 5
Return this many descending sorted values.
keep : {'first', 'last'}, default 'first'
When there are duplicate values that cannot all fit in a
Series of `n` elements:
- ``first`` : return the first `n` occurrences in order
of appearance.
- ``last`` : return the last `n` occurrences in reverse
order of appearance.
Returns
-------
Series
The `n` largest values in the Series, sorted in decreasing order.
Examples
--------
>>> import cudf
>>> countries_population = {"Italy": 59000000, "France": 65000000,
... "Malta": 434000, "Maldives": 434000,
... "Brunei": 434000, "Iceland": 337000,
... "Nauru": 11300, "Tuvalu": 11300,
... "Anguilla": 11300, "Montserrat": 5200}
>>> series = cudf.Series(countries_population)
>>> series
Italy 59000000
France 65000000
Malta 434000
Maldives 434000
Brunei 434000
Iceland 337000
Nauru 11300
Tuvalu 11300
Anguilla 11300
Montserrat 5200
dtype: int64
>>> series.nlargest()
France 65000000
Italy 59000000
Malta 434000
Maldives 434000
Brunei 434000
dtype: int64
>>> series.nlargest(3)
France 65000000
Italy 59000000
Malta 434000
dtype: int64
>>> series.nlargest(3, keep='last')
France 65000000
Italy 59000000
Brunei 434000
dtype: int64<|endoftext|> |
d4d382e88c2ce1edd4cdd2c09989061bffe75106f8d7eb22cb422f922aec75ad | def nsmallest(self, n=5, keep='first'):
'\n Returns a new Series of the *n* smallest element.\n\n Parameters\n ----------\n n : int, default 5\n Return this many ascending sorted values.\n keep : {\'first\', \'last\'}, default \'first\'\n When there are duplicate values that cannot all fit in a\n Series of `n` elements:\n\n - ``first`` : return the first `n` occurrences in order\n of appearance.\n - ``last`` : return the last `n` occurrences in reverse\n order of appearance.\n\n Returns\n -------\n Series\n The `n` smallest values in the Series, sorted in increasing order.\n\n Examples\n --------\n >>> import cudf\n >>> countries_population = {"Italy": 59000000, "France": 65000000,\n ... "Brunei": 434000, "Malta": 434000,\n ... "Maldives": 434000, "Iceland": 337000,\n ... "Nauru": 11300, "Tuvalu": 11300,\n ... "Anguilla": 11300, "Montserrat": 5200}\n >>> s = cudf.Series(countries_population)\n >>> s\n Italy 59000000\n France 65000000\n Brunei 434000\n Malta 434000\n Maldives 434000\n Iceland 337000\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Montserrat 5200\n dtype: int64\n\n The `n` smallest elements where ``n=5`` by default.\n\n >>> s.nsmallest()\n Montserrat 5200\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Iceland 337000\n dtype: int64\n\n The `n` smallest elements where ``n=3``. Default `keep` value is\n \'first\' so Nauru and Tuvalu will be kept.\n\n >>> s.nsmallest(3)\n Montserrat 5200\n Nauru 11300\n Tuvalu 11300\n dtype: int64\n\n The `n` smallest elements where ``n=3`` and keeping the last\n duplicates. Anguilla and Tuvalu will be kept since they are the last\n with value 11300 based on the index order.\n\n >>> s.nsmallest(3, keep=\'last\')\n Montserrat 5200\n Anguilla 11300\n Tuvalu 11300\n dtype: int64\n '
return self._n_largest_or_smallest(n=n, keep=keep, largest=False) | Returns a new Series of the *n* smallest element.
Parameters
----------
n : int, default 5
Return this many ascending sorted values.
keep : {'first', 'last'}, default 'first'
When there are duplicate values that cannot all fit in a
Series of `n` elements:
- ``first`` : return the first `n` occurrences in order
of appearance.
- ``last`` : return the last `n` occurrences in reverse
order of appearance.
Returns
-------
Series
The `n` smallest values in the Series, sorted in increasing order.
Examples
--------
>>> import cudf
>>> countries_population = {"Italy": 59000000, "France": 65000000,
... "Brunei": 434000, "Malta": 434000,
... "Maldives": 434000, "Iceland": 337000,
... "Nauru": 11300, "Tuvalu": 11300,
... "Anguilla": 11300, "Montserrat": 5200}
>>> s = cudf.Series(countries_population)
>>> s
Italy 59000000
France 65000000
Brunei 434000
Malta 434000
Maldives 434000
Iceland 337000
Nauru 11300
Tuvalu 11300
Anguilla 11300
Montserrat 5200
dtype: int64
The `n` smallest elements where ``n=5`` by default.
>>> s.nsmallest()
Montserrat 5200
Nauru 11300
Tuvalu 11300
Anguilla 11300
Iceland 337000
dtype: int64
The `n` smallest elements where ``n=3``. Default `keep` value is
'first' so Nauru and Tuvalu will be kept.
>>> s.nsmallest(3)
Montserrat 5200
Nauru 11300
Tuvalu 11300
dtype: int64
The `n` smallest elements where ``n=3`` and keeping the last
duplicates. Anguilla and Tuvalu will be kept since they are the last
with value 11300 based on the index order.
>>> s.nsmallest(3, keep='last')
Montserrat 5200
Anguilla 11300
Tuvalu 11300
dtype: int64 | python/cudf/cudf/core/series.py | nsmallest | jdye64/cudf | 1 | python | def nsmallest(self, n=5, keep='first'):
'\n Returns a new Series of the *n* smallest element.\n\n Parameters\n ----------\n n : int, default 5\n Return this many ascending sorted values.\n keep : {\'first\', \'last\'}, default \'first\'\n When there are duplicate values that cannot all fit in a\n Series of `n` elements:\n\n - ``first`` : return the first `n` occurrences in order\n of appearance.\n - ``last`` : return the last `n` occurrences in reverse\n order of appearance.\n\n Returns\n -------\n Series\n The `n` smallest values in the Series, sorted in increasing order.\n\n Examples\n --------\n >>> import cudf\n >>> countries_population = {"Italy": 59000000, "France": 65000000,\n ... "Brunei": 434000, "Malta": 434000,\n ... "Maldives": 434000, "Iceland": 337000,\n ... "Nauru": 11300, "Tuvalu": 11300,\n ... "Anguilla": 11300, "Montserrat": 5200}\n >>> s = cudf.Series(countries_population)\n >>> s\n Italy 59000000\n France 65000000\n Brunei 434000\n Malta 434000\n Maldives 434000\n Iceland 337000\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Montserrat 5200\n dtype: int64\n\n The `n` smallest elements where ``n=5`` by default.\n\n >>> s.nsmallest()\n Montserrat 5200\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Iceland 337000\n dtype: int64\n\n The `n` smallest elements where ``n=3``. Default `keep` value is\n \'first\' so Nauru and Tuvalu will be kept.\n\n >>> s.nsmallest(3)\n Montserrat 5200\n Nauru 11300\n Tuvalu 11300\n dtype: int64\n\n The `n` smallest elements where ``n=3`` and keeping the last\n duplicates. Anguilla and Tuvalu will be kept since they are the last\n with value 11300 based on the index order.\n\n >>> s.nsmallest(3, keep=\'last\')\n Montserrat 5200\n Anguilla 11300\n Tuvalu 11300\n dtype: int64\n '
return self._n_largest_or_smallest(n=n, keep=keep, largest=False) | def nsmallest(self, n=5, keep='first'):
'\n Returns a new Series of the *n* smallest element.\n\n Parameters\n ----------\n n : int, default 5\n Return this many ascending sorted values.\n keep : {\'first\', \'last\'}, default \'first\'\n When there are duplicate values that cannot all fit in a\n Series of `n` elements:\n\n - ``first`` : return the first `n` occurrences in order\n of appearance.\n - ``last`` : return the last `n` occurrences in reverse\n order of appearance.\n\n Returns\n -------\n Series\n The `n` smallest values in the Series, sorted in increasing order.\n\n Examples\n --------\n >>> import cudf\n >>> countries_population = {"Italy": 59000000, "France": 65000000,\n ... "Brunei": 434000, "Malta": 434000,\n ... "Maldives": 434000, "Iceland": 337000,\n ... "Nauru": 11300, "Tuvalu": 11300,\n ... "Anguilla": 11300, "Montserrat": 5200}\n >>> s = cudf.Series(countries_population)\n >>> s\n Italy 59000000\n France 65000000\n Brunei 434000\n Malta 434000\n Maldives 434000\n Iceland 337000\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Montserrat 5200\n dtype: int64\n\n The `n` smallest elements where ``n=5`` by default.\n\n >>> s.nsmallest()\n Montserrat 5200\n Nauru 11300\n Tuvalu 11300\n Anguilla 11300\n Iceland 337000\n dtype: int64\n\n The `n` smallest elements where ``n=3``. Default `keep` value is\n \'first\' so Nauru and Tuvalu will be kept.\n\n >>> s.nsmallest(3)\n Montserrat 5200\n Nauru 11300\n Tuvalu 11300\n dtype: int64\n\n The `n` smallest elements where ``n=3`` and keeping the last\n duplicates. Anguilla and Tuvalu will be kept since they are the last\n with value 11300 based on the index order.\n\n >>> s.nsmallest(3, keep=\'last\')\n Montserrat 5200\n Anguilla 11300\n Tuvalu 11300\n dtype: int64\n '
return self._n_largest_or_smallest(n=n, keep=keep, largest=False)<|docstring|>Returns a new Series of the *n* smallest element.
Parameters
----------
n : int, default 5
Return this many ascending sorted values.
keep : {'first', 'last'}, default 'first'
When there are duplicate values that cannot all fit in a
Series of `n` elements:
- ``first`` : return the first `n` occurrences in order
of appearance.
- ``last`` : return the last `n` occurrences in reverse
order of appearance.
Returns
-------
Series
The `n` smallest values in the Series, sorted in increasing order.
Examples
--------
>>> import cudf
>>> countries_population = {"Italy": 59000000, "France": 65000000,
... "Brunei": 434000, "Malta": 434000,
... "Maldives": 434000, "Iceland": 337000,
... "Nauru": 11300, "Tuvalu": 11300,
... "Anguilla": 11300, "Montserrat": 5200}
>>> s = cudf.Series(countries_population)
>>> s
Italy 59000000
France 65000000
Brunei 434000
Malta 434000
Maldives 434000
Iceland 337000
Nauru 11300
Tuvalu 11300
Anguilla 11300
Montserrat 5200
dtype: int64
The `n` smallest elements where ``n=5`` by default.
>>> s.nsmallest()
Montserrat 5200
Nauru 11300
Tuvalu 11300
Anguilla 11300
Iceland 337000
dtype: int64
The `n` smallest elements where ``n=3``. Default `keep` value is
'first' so Nauru and Tuvalu will be kept.
>>> s.nsmallest(3)
Montserrat 5200
Nauru 11300
Tuvalu 11300
dtype: int64
The `n` smallest elements where ``n=3`` and keeping the last
duplicates. Anguilla and Tuvalu will be kept since they are the last
with value 11300 based on the index order.
>>> s.nsmallest(3, keep='last')
Montserrat 5200
Anguilla 11300
Tuvalu 11300
dtype: int64<|endoftext|> |
68d306e4e0d740865e67bb238c7e60b5cc9a195e5a14eda1ed25755b142b9311 | def _sort(self, ascending=True, na_position='last'):
'\n Sort by values\n\n Returns\n -------\n 2-tuple of key and index\n '
(col_keys, col_inds) = self._column.sort_by_values(ascending=ascending, na_position=na_position)
sr_keys = self._from_data({self.name: col_keys}, self._index)
sr_inds = self._from_data({self.name: col_inds}, self._index)
return (sr_keys, sr_inds) | Sort by values
Returns
-------
2-tuple of key and index | python/cudf/cudf/core/series.py | _sort | jdye64/cudf | 1 | python | def _sort(self, ascending=True, na_position='last'):
'\n Sort by values\n\n Returns\n -------\n 2-tuple of key and index\n '
(col_keys, col_inds) = self._column.sort_by_values(ascending=ascending, na_position=na_position)
sr_keys = self._from_data({self.name: col_keys}, self._index)
sr_inds = self._from_data({self.name: col_inds}, self._index)
return (sr_keys, sr_inds) | def _sort(self, ascending=True, na_position='last'):
'\n Sort by values\n\n Returns\n -------\n 2-tuple of key and index\n '
(col_keys, col_inds) = self._column.sort_by_values(ascending=ascending, na_position=na_position)
sr_keys = self._from_data({self.name: col_keys}, self._index)
sr_inds = self._from_data({self.name: col_inds}, self._index)
return (sr_keys, sr_inds)<|docstring|>Sort by values
Returns
-------
2-tuple of key and index<|endoftext|> |
6b87f6eb6f931d142a613b89d174ff169262ffa6650fec3f2d2c706fba55832c | def replace(self, to_replace=None, value=None, inplace=False, limit=None, regex=False, method=None):
"\n Replace values given in ``to_replace`` with ``value``.\n\n Parameters\n ----------\n to_replace : numeric, str or list-like\n Value(s) to replace.\n\n * numeric or str:\n - values equal to ``to_replace`` will be replaced\n with ``value``\n * list of numeric or str:\n - If ``value`` is also list-like, ``to_replace`` and\n ``value`` must be of same length.\n * dict:\n - Dicts can be used to specify different replacement values\n for different existing values. For example, {'a': 'b',\n 'y': 'z'} replaces the value ‘a’ with ‘b’ and\n ‘y’ with ‘z’.\n To use a dict in this way the ``value`` parameter should\n be ``None``.\n value : scalar, dict, list-like, str, default None\n Value to replace any values matching ``to_replace`` with.\n inplace : bool, default False\n If True, in place.\n\n See also\n --------\n Series.fillna\n\n Raises\n ------\n TypeError\n - If ``to_replace`` is not a scalar, array-like, dict, or None\n - If ``to_replace`` is a dict and value is not a list, dict,\n or Series\n ValueError\n - If a list is passed to ``to_replace`` and ``value`` but they\n are not the same length.\n\n Returns\n -------\n result : Series\n Series after replacement. The mask and index are preserved.\n\n Notes\n -----\n Parameters that are currently not supported are: `limit`, `regex`,\n `method`\n\n Examples\n --------\n\n Scalar ``to_replace`` and ``value``\n\n >>> import cudf\n >>> s = cudf.Series([0, 1, 2, 3, 4])\n >>> s\n 0 0\n 1 1\n 2 2\n 3 3\n 4 4\n dtype: int64\n >>> s.replace(0, 5)\n 0 5\n 1 1\n 2 2\n 3 3\n 4 4\n dtype: int64\n\n List-like ``to_replace``\n\n >>> s.replace([1, 2], 10)\n 0 0\n 1 10\n 2 10\n 3 3\n 4 4\n dtype: int64\n\n dict-like ``to_replace``\n\n >>> s.replace({1:5, 3:50})\n 0 0\n 1 5\n 2 2\n 3 50\n 4 4\n dtype: int64\n >>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])\n >>> s\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace({'a': None})\n 0 b\n 1 <NA>\n 2 <NA>\n 3 b\n 4 <NA>\n dtype: object\n\n If there is a mimatch in types of the values in\n ``to_replace`` & ``value`` with the actual series, then\n cudf exhibits different behaviour with respect to pandas\n and the pairs are ignored silently:\n\n >>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])\n >>> s\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace('a', 1)\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace(['a', 'c'], [1, 2])\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n "
if (limit is not None):
raise NotImplementedError('limit parameter is not implemented yet')
if regex:
raise NotImplementedError('regex parameter is not implemented yet')
if (method not in ('pad', None)):
raise NotImplementedError('method parameter is not implemented yet')
if (is_dict_like(to_replace) and (value is not None)):
raise ValueError('Series.replace cannot use dict-like to_replace and non-None value')
result = super().replace(to_replace=to_replace, replacement=value)
return self._mimic_inplace(result, inplace=inplace) | Replace values given in ``to_replace`` with ``value``.
Parameters
----------
to_replace : numeric, str or list-like
Value(s) to replace.
* numeric or str:
- values equal to ``to_replace`` will be replaced
with ``value``
* list of numeric or str:
- If ``value`` is also list-like, ``to_replace`` and
``value`` must be of same length.
* dict:
- Dicts can be used to specify different replacement values
for different existing values. For example, {'a': 'b',
'y': 'z'} replaces the value ‘a’ with ‘b’ and
‘y’ with ‘z’.
To use a dict in this way the ``value`` parameter should
be ``None``.
value : scalar, dict, list-like, str, default None
Value to replace any values matching ``to_replace`` with.
inplace : bool, default False
If True, in place.
See also
--------
Series.fillna
Raises
------
TypeError
- If ``to_replace`` is not a scalar, array-like, dict, or None
- If ``to_replace`` is a dict and value is not a list, dict,
or Series
ValueError
- If a list is passed to ``to_replace`` and ``value`` but they
are not the same length.
Returns
-------
result : Series
Series after replacement. The mask and index are preserved.
Notes
-----
Parameters that are currently not supported are: `limit`, `regex`,
`method`
Examples
--------
Scalar ``to_replace`` and ``value``
>>> import cudf
>>> s = cudf.Series([0, 1, 2, 3, 4])
>>> s
0 0
1 1
2 2
3 3
4 4
dtype: int64
>>> s.replace(0, 5)
0 5
1 1
2 2
3 3
4 4
dtype: int64
List-like ``to_replace``
>>> s.replace([1, 2], 10)
0 0
1 10
2 10
3 3
4 4
dtype: int64
dict-like ``to_replace``
>>> s.replace({1:5, 3:50})
0 0
1 5
2 2
3 50
4 4
dtype: int64
>>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])
>>> s
0 b
1 a
2 a
3 b
4 a
dtype: object
>>> s.replace({'a': None})
0 b
1 <NA>
2 <NA>
3 b
4 <NA>
dtype: object
If there is a mimatch in types of the values in
``to_replace`` & ``value`` with the actual series, then
cudf exhibits different behaviour with respect to pandas
and the pairs are ignored silently:
>>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])
>>> s
0 b
1 a
2 a
3 b
4 a
dtype: object
>>> s.replace('a', 1)
0 b
1 a
2 a
3 b
4 a
dtype: object
>>> s.replace(['a', 'c'], [1, 2])
0 b
1 a
2 a
3 b
4 a
dtype: object | python/cudf/cudf/core/series.py | replace | jdye64/cudf | 1 | python | def replace(self, to_replace=None, value=None, inplace=False, limit=None, regex=False, method=None):
"\n Replace values given in ``to_replace`` with ``value``.\n\n Parameters\n ----------\n to_replace : numeric, str or list-like\n Value(s) to replace.\n\n * numeric or str:\n - values equal to ``to_replace`` will be replaced\n with ``value``\n * list of numeric or str:\n - If ``value`` is also list-like, ``to_replace`` and\n ``value`` must be of same length.\n * dict:\n - Dicts can be used to specify different replacement values\n for different existing values. For example, {'a': 'b',\n 'y': 'z'} replaces the value ‘a’ with ‘b’ and\n ‘y’ with ‘z’.\n To use a dict in this way the ``value`` parameter should\n be ``None``.\n value : scalar, dict, list-like, str, default None\n Value to replace any values matching ``to_replace`` with.\n inplace : bool, default False\n If True, in place.\n\n See also\n --------\n Series.fillna\n\n Raises\n ------\n TypeError\n - If ``to_replace`` is not a scalar, array-like, dict, or None\n - If ``to_replace`` is a dict and value is not a list, dict,\n or Series\n ValueError\n - If a list is passed to ``to_replace`` and ``value`` but they\n are not the same length.\n\n Returns\n -------\n result : Series\n Series after replacement. The mask and index are preserved.\n\n Notes\n -----\n Parameters that are currently not supported are: `limit`, `regex`,\n `method`\n\n Examples\n --------\n\n Scalar ``to_replace`` and ``value``\n\n >>> import cudf\n >>> s = cudf.Series([0, 1, 2, 3, 4])\n >>> s\n 0 0\n 1 1\n 2 2\n 3 3\n 4 4\n dtype: int64\n >>> s.replace(0, 5)\n 0 5\n 1 1\n 2 2\n 3 3\n 4 4\n dtype: int64\n\n List-like ``to_replace``\n\n >>> s.replace([1, 2], 10)\n 0 0\n 1 10\n 2 10\n 3 3\n 4 4\n dtype: int64\n\n dict-like ``to_replace``\n\n >>> s.replace({1:5, 3:50})\n 0 0\n 1 5\n 2 2\n 3 50\n 4 4\n dtype: int64\n >>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])\n >>> s\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace({'a': None})\n 0 b\n 1 <NA>\n 2 <NA>\n 3 b\n 4 <NA>\n dtype: object\n\n If there is a mimatch in types of the values in\n ``to_replace`` & ``value`` with the actual series, then\n cudf exhibits different behaviour with respect to pandas\n and the pairs are ignored silently:\n\n >>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])\n >>> s\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace('a', 1)\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace(['a', 'c'], [1, 2])\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n "
if (limit is not None):
raise NotImplementedError('limit parameter is not implemented yet')
if regex:
raise NotImplementedError('regex parameter is not implemented yet')
if (method not in ('pad', None)):
raise NotImplementedError('method parameter is not implemented yet')
if (is_dict_like(to_replace) and (value is not None)):
raise ValueError('Series.replace cannot use dict-like to_replace and non-None value')
result = super().replace(to_replace=to_replace, replacement=value)
return self._mimic_inplace(result, inplace=inplace) | def replace(self, to_replace=None, value=None, inplace=False, limit=None, regex=False, method=None):
"\n Replace values given in ``to_replace`` with ``value``.\n\n Parameters\n ----------\n to_replace : numeric, str or list-like\n Value(s) to replace.\n\n * numeric or str:\n - values equal to ``to_replace`` will be replaced\n with ``value``\n * list of numeric or str:\n - If ``value`` is also list-like, ``to_replace`` and\n ``value`` must be of same length.\n * dict:\n - Dicts can be used to specify different replacement values\n for different existing values. For example, {'a': 'b',\n 'y': 'z'} replaces the value ‘a’ with ‘b’ and\n ‘y’ with ‘z’.\n To use a dict in this way the ``value`` parameter should\n be ``None``.\n value : scalar, dict, list-like, str, default None\n Value to replace any values matching ``to_replace`` with.\n inplace : bool, default False\n If True, in place.\n\n See also\n --------\n Series.fillna\n\n Raises\n ------\n TypeError\n - If ``to_replace`` is not a scalar, array-like, dict, or None\n - If ``to_replace`` is a dict and value is not a list, dict,\n or Series\n ValueError\n - If a list is passed to ``to_replace`` and ``value`` but they\n are not the same length.\n\n Returns\n -------\n result : Series\n Series after replacement. The mask and index are preserved.\n\n Notes\n -----\n Parameters that are currently not supported are: `limit`, `regex`,\n `method`\n\n Examples\n --------\n\n Scalar ``to_replace`` and ``value``\n\n >>> import cudf\n >>> s = cudf.Series([0, 1, 2, 3, 4])\n >>> s\n 0 0\n 1 1\n 2 2\n 3 3\n 4 4\n dtype: int64\n >>> s.replace(0, 5)\n 0 5\n 1 1\n 2 2\n 3 3\n 4 4\n dtype: int64\n\n List-like ``to_replace``\n\n >>> s.replace([1, 2], 10)\n 0 0\n 1 10\n 2 10\n 3 3\n 4 4\n dtype: int64\n\n dict-like ``to_replace``\n\n >>> s.replace({1:5, 3:50})\n 0 0\n 1 5\n 2 2\n 3 50\n 4 4\n dtype: int64\n >>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])\n >>> s\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace({'a': None})\n 0 b\n 1 <NA>\n 2 <NA>\n 3 b\n 4 <NA>\n dtype: object\n\n If there is a mimatch in types of the values in\n ``to_replace`` & ``value`` with the actual series, then\n cudf exhibits different behaviour with respect to pandas\n and the pairs are ignored silently:\n\n >>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])\n >>> s\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace('a', 1)\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n >>> s.replace(['a', 'c'], [1, 2])\n 0 b\n 1 a\n 2 a\n 3 b\n 4 a\n dtype: object\n "
if (limit is not None):
raise NotImplementedError('limit parameter is not implemented yet')
if regex:
raise NotImplementedError('regex parameter is not implemented yet')
if (method not in ('pad', None)):
raise NotImplementedError('method parameter is not implemented yet')
if (is_dict_like(to_replace) and (value is not None)):
raise ValueError('Series.replace cannot use dict-like to_replace and non-None value')
result = super().replace(to_replace=to_replace, replacement=value)
return self._mimic_inplace(result, inplace=inplace)<|docstring|>Replace values given in ``to_replace`` with ``value``.
Parameters
----------
to_replace : numeric, str or list-like
Value(s) to replace.
* numeric or str:
- values equal to ``to_replace`` will be replaced
with ``value``
* list of numeric or str:
- If ``value`` is also list-like, ``to_replace`` and
``value`` must be of same length.
* dict:
- Dicts can be used to specify different replacement values
for different existing values. For example, {'a': 'b',
'y': 'z'} replaces the value ‘a’ with ‘b’ and
‘y’ with ‘z’.
To use a dict in this way the ``value`` parameter should
be ``None``.
value : scalar, dict, list-like, str, default None
Value to replace any values matching ``to_replace`` with.
inplace : bool, default False
If True, in place.
See also
--------
Series.fillna
Raises
------
TypeError
- If ``to_replace`` is not a scalar, array-like, dict, or None
- If ``to_replace`` is a dict and value is not a list, dict,
or Series
ValueError
- If a list is passed to ``to_replace`` and ``value`` but they
are not the same length.
Returns
-------
result : Series
Series after replacement. The mask and index are preserved.
Notes
-----
Parameters that are currently not supported are: `limit`, `regex`,
`method`
Examples
--------
Scalar ``to_replace`` and ``value``
>>> import cudf
>>> s = cudf.Series([0, 1, 2, 3, 4])
>>> s
0 0
1 1
2 2
3 3
4 4
dtype: int64
>>> s.replace(0, 5)
0 5
1 1
2 2
3 3
4 4
dtype: int64
List-like ``to_replace``
>>> s.replace([1, 2], 10)
0 0
1 10
2 10
3 3
4 4
dtype: int64
dict-like ``to_replace``
>>> s.replace({1:5, 3:50})
0 0
1 5
2 2
3 50
4 4
dtype: int64
>>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])
>>> s
0 b
1 a
2 a
3 b
4 a
dtype: object
>>> s.replace({'a': None})
0 b
1 <NA>
2 <NA>
3 b
4 <NA>
dtype: object
If there is a mimatch in types of the values in
``to_replace`` & ``value`` with the actual series, then
cudf exhibits different behaviour with respect to pandas
and the pairs are ignored silently:
>>> s = cudf.Series(['b', 'a', 'a', 'b', 'a'])
>>> s
0 b
1 a
2 a
3 b
4 a
dtype: object
>>> s.replace('a', 1)
0 b
1 a
2 a
3 b
4 a
dtype: object
>>> s.replace(['a', 'c'], [1, 2])
0 b
1 a
2 a
3 b
4 a
dtype: object<|endoftext|> |
78f08a4d3f7a393fe2f68cf36cee2df3d70b8731689720696b408d192c0345d7 | def update(self, other):
"\n Modify Series in place using values from passed Series.\n Uses non-NA values from passed Series to make updates. Aligns\n on index.\n\n Parameters\n ----------\n other : Series, or object coercible into Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, 5, 6]))\n >>> s\n 0 4\n 1 5\n 2 6\n dtype: int64\n >>> s = cudf.Series(['a', 'b', 'c'])\n >>> s\n 0 a\n 1 b\n 2 c\n dtype: object\n >>> s.update(cudf.Series(['d', 'e'], index=[0, 2]))\n >>> s\n 0 d\n 1 b\n 2 e\n dtype: object\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, 5, 6, 7, 8]))\n >>> s\n 0 4\n 1 5\n 2 6\n dtype: int64\n\n If ``other`` contains NaNs the corresponding values are not updated\n in the original Series.\n\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, np.nan, 6], nan_as_null=False))\n >>> s\n 0 4\n 1 2\n 2 6\n dtype: int64\n\n ``other`` can also be a non-Series object type\n that is coercible into a Series\n\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update([4, np.nan, 6])\n >>> s\n 0 4\n 1 2\n 2 6\n dtype: int64\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update({1: 9})\n >>> s\n 0 1\n 1 9\n 2 3\n dtype: int64\n "
if (not isinstance(other, cudf.Series)):
other = cudf.Series(other)
if (not self.index.equals(other.index)):
other = other.reindex(index=self.index)
mask = other.notna()
self.mask(mask, other, inplace=True) | Modify Series in place using values from passed Series.
Uses non-NA values from passed Series to make updates. Aligns
on index.
Parameters
----------
other : Series, or object coercible into Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update(cudf.Series([4, 5, 6]))
>>> s
0 4
1 5
2 6
dtype: int64
>>> s = cudf.Series(['a', 'b', 'c'])
>>> s
0 a
1 b
2 c
dtype: object
>>> s.update(cudf.Series(['d', 'e'], index=[0, 2]))
>>> s
0 d
1 b
2 e
dtype: object
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update(cudf.Series([4, 5, 6, 7, 8]))
>>> s
0 4
1 5
2 6
dtype: int64
If ``other`` contains NaNs the corresponding values are not updated
in the original Series.
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update(cudf.Series([4, np.nan, 6], nan_as_null=False))
>>> s
0 4
1 2
2 6
dtype: int64
``other`` can also be a non-Series object type
that is coercible into a Series
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update([4, np.nan, 6])
>>> s
0 4
1 2
2 6
dtype: int64
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update({1: 9})
>>> s
0 1
1 9
2 3
dtype: int64 | python/cudf/cudf/core/series.py | update | jdye64/cudf | 1 | python | def update(self, other):
"\n Modify Series in place using values from passed Series.\n Uses non-NA values from passed Series to make updates. Aligns\n on index.\n\n Parameters\n ----------\n other : Series, or object coercible into Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, 5, 6]))\n >>> s\n 0 4\n 1 5\n 2 6\n dtype: int64\n >>> s = cudf.Series(['a', 'b', 'c'])\n >>> s\n 0 a\n 1 b\n 2 c\n dtype: object\n >>> s.update(cudf.Series(['d', 'e'], index=[0, 2]))\n >>> s\n 0 d\n 1 b\n 2 e\n dtype: object\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, 5, 6, 7, 8]))\n >>> s\n 0 4\n 1 5\n 2 6\n dtype: int64\n\n If ``other`` contains NaNs the corresponding values are not updated\n in the original Series.\n\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, np.nan, 6], nan_as_null=False))\n >>> s\n 0 4\n 1 2\n 2 6\n dtype: int64\n\n ``other`` can also be a non-Series object type\n that is coercible into a Series\n\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update([4, np.nan, 6])\n >>> s\n 0 4\n 1 2\n 2 6\n dtype: int64\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update({1: 9})\n >>> s\n 0 1\n 1 9\n 2 3\n dtype: int64\n "
if (not isinstance(other, cudf.Series)):
other = cudf.Series(other)
if (not self.index.equals(other.index)):
other = other.reindex(index=self.index)
mask = other.notna()
self.mask(mask, other, inplace=True) | def update(self, other):
"\n Modify Series in place using values from passed Series.\n Uses non-NA values from passed Series to make updates. Aligns\n on index.\n\n Parameters\n ----------\n other : Series, or object coercible into Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, 5, 6]))\n >>> s\n 0 4\n 1 5\n 2 6\n dtype: int64\n >>> s = cudf.Series(['a', 'b', 'c'])\n >>> s\n 0 a\n 1 b\n 2 c\n dtype: object\n >>> s.update(cudf.Series(['d', 'e'], index=[0, 2]))\n >>> s\n 0 d\n 1 b\n 2 e\n dtype: object\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, 5, 6, 7, 8]))\n >>> s\n 0 4\n 1 5\n 2 6\n dtype: int64\n\n If ``other`` contains NaNs the corresponding values are not updated\n in the original Series.\n\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update(cudf.Series([4, np.nan, 6], nan_as_null=False))\n >>> s\n 0 4\n 1 2\n 2 6\n dtype: int64\n\n ``other`` can also be a non-Series object type\n that is coercible into a Series\n\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update([4, np.nan, 6])\n >>> s\n 0 4\n 1 2\n 2 6\n dtype: int64\n >>> s = cudf.Series([1, 2, 3])\n >>> s\n 0 1\n 1 2\n 2 3\n dtype: int64\n >>> s.update({1: 9})\n >>> s\n 0 1\n 1 9\n 2 3\n dtype: int64\n "
if (not isinstance(other, cudf.Series)):
other = cudf.Series(other)
if (not self.index.equals(other.index)):
other = other.reindex(index=self.index)
mask = other.notna()
self.mask(mask, other, inplace=True)<|docstring|>Modify Series in place using values from passed Series.
Uses non-NA values from passed Series to make updates. Aligns
on index.
Parameters
----------
other : Series, or object coercible into Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update(cudf.Series([4, 5, 6]))
>>> s
0 4
1 5
2 6
dtype: int64
>>> s = cudf.Series(['a', 'b', 'c'])
>>> s
0 a
1 b
2 c
dtype: object
>>> s.update(cudf.Series(['d', 'e'], index=[0, 2]))
>>> s
0 d
1 b
2 e
dtype: object
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update(cudf.Series([4, 5, 6, 7, 8]))
>>> s
0 4
1 5
2 6
dtype: int64
If ``other`` contains NaNs the corresponding values are not updated
in the original Series.
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update(cudf.Series([4, np.nan, 6], nan_as_null=False))
>>> s
0 4
1 2
2 6
dtype: int64
``other`` can also be a non-Series object type
that is coercible into a Series
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update([4, np.nan, 6])
>>> s
0 4
1 2
2 6
dtype: int64
>>> s = cudf.Series([1, 2, 3])
>>> s
0 1
1 2
2 3
dtype: int64
>>> s.update({1: 9})
>>> s
0 1
1 9
2 3
dtype: int64<|endoftext|> |
a45fb477909cdc3180ed4202648b05f579ddb002b2c5d806df2c11e70ccbd698 | def reverse(self):
'\n Reverse the Series\n\n Returns\n -------\n Series\n A reversed Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4, 5, 6])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n dtype: int64\n >>> series.reverse()\n 5 6\n 4 5\n 3 4\n 2 3\n 1 2\n 0 1\n dtype: int64\n '
rinds = column.arange((self._column.size - 1), (- 1), (- 1), dtype=np.int32)
return self._from_data({self.name: self._column[rinds]}, self.index._values[rinds]) | Reverse the Series
Returns
-------
Series
A reversed Series.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4, 5, 6])
>>> series
0 1
1 2
2 3
3 4
4 5
5 6
dtype: int64
>>> series.reverse()
5 6
4 5
3 4
2 3
1 2
0 1
dtype: int64 | python/cudf/cudf/core/series.py | reverse | jdye64/cudf | 1 | python | def reverse(self):
'\n Reverse the Series\n\n Returns\n -------\n Series\n A reversed Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4, 5, 6])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n dtype: int64\n >>> series.reverse()\n 5 6\n 4 5\n 3 4\n 2 3\n 1 2\n 0 1\n dtype: int64\n '
rinds = column.arange((self._column.size - 1), (- 1), (- 1), dtype=np.int32)
return self._from_data({self.name: self._column[rinds]}, self.index._values[rinds]) | def reverse(self):
'\n Reverse the Series\n\n Returns\n -------\n Series\n A reversed Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4, 5, 6])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n dtype: int64\n >>> series.reverse()\n 5 6\n 4 5\n 3 4\n 2 3\n 1 2\n 0 1\n dtype: int64\n '
rinds = column.arange((self._column.size - 1), (- 1), (- 1), dtype=np.int32)
return self._from_data({self.name: self._column[rinds]}, self.index._values[rinds])<|docstring|>Reverse the Series
Returns
-------
Series
A reversed Series.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4, 5, 6])
>>> series
0 1
1 2
2 3
3 4
4 5
5 6
dtype: int64
>>> series.reverse()
5 6
4 5
3 4
2 3
1 2
0 1
dtype: int64<|endoftext|> |
a19742f09a7fe57ca8b809fc800572991b215556394ff146b8ce5dee78573252 | def one_hot_encoding(self, cats, dtype='float64'):
"Perform one-hot-encoding\n\n Parameters\n ----------\n cats : sequence of values\n values representing each category.\n dtype : numpy.dtype\n specifies the output dtype.\n\n Returns\n -------\n Sequence\n A sequence of new series for each category. Its length is\n determined by the length of ``cats``.\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series(['a', 'b', 'c', 'a'])\n >>> s\n 0 a\n 1 b\n 2 c\n 3 a\n dtype: object\n >>> s.one_hot_encoding(['a', 'c', 'b'])\n [0 1.0\n 1 0.0\n 2 0.0\n 3 1.0\n dtype: float64, 0 0.0\n 1 0.0\n 2 1.0\n 3 0.0\n dtype: float64, 0 0.0\n 1 1.0\n 2 0.0\n 3 0.0\n dtype: float64]\n "
if hasattr(cats, 'to_arrow'):
cats = cats.to_pandas()
else:
cats = pd.Series(cats, dtype='object')
dtype = cudf.dtype(dtype)
def encode(cat):
if (cat is None):
if (self.dtype.kind == 'f'):
return self.__class__(libcudf.unary.is_null(self._column))
else:
return self.isnull()
elif (np.issubdtype(type(cat), np.floating) and np.isnan(cat)):
return self.__class__(libcudf.unary.is_nan(self._column))
else:
return (self == cat).fillna(False)
return [encode(cat).astype(dtype) for cat in cats] | Perform one-hot-encoding
Parameters
----------
cats : sequence of values
values representing each category.
dtype : numpy.dtype
specifies the output dtype.
Returns
-------
Sequence
A sequence of new series for each category. Its length is
determined by the length of ``cats``.
Examples
--------
>>> import cudf
>>> s = cudf.Series(['a', 'b', 'c', 'a'])
>>> s
0 a
1 b
2 c
3 a
dtype: object
>>> s.one_hot_encoding(['a', 'c', 'b'])
[0 1.0
1 0.0
2 0.0
3 1.0
dtype: float64, 0 0.0
1 0.0
2 1.0
3 0.0
dtype: float64, 0 0.0
1 1.0
2 0.0
3 0.0
dtype: float64] | python/cudf/cudf/core/series.py | one_hot_encoding | jdye64/cudf | 1 | python | def one_hot_encoding(self, cats, dtype='float64'):
"Perform one-hot-encoding\n\n Parameters\n ----------\n cats : sequence of values\n values representing each category.\n dtype : numpy.dtype\n specifies the output dtype.\n\n Returns\n -------\n Sequence\n A sequence of new series for each category. Its length is\n determined by the length of ``cats``.\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series(['a', 'b', 'c', 'a'])\n >>> s\n 0 a\n 1 b\n 2 c\n 3 a\n dtype: object\n >>> s.one_hot_encoding(['a', 'c', 'b'])\n [0 1.0\n 1 0.0\n 2 0.0\n 3 1.0\n dtype: float64, 0 0.0\n 1 0.0\n 2 1.0\n 3 0.0\n dtype: float64, 0 0.0\n 1 1.0\n 2 0.0\n 3 0.0\n dtype: float64]\n "
if hasattr(cats, 'to_arrow'):
cats = cats.to_pandas()
else:
cats = pd.Series(cats, dtype='object')
dtype = cudf.dtype(dtype)
def encode(cat):
if (cat is None):
if (self.dtype.kind == 'f'):
return self.__class__(libcudf.unary.is_null(self._column))
else:
return self.isnull()
elif (np.issubdtype(type(cat), np.floating) and np.isnan(cat)):
return self.__class__(libcudf.unary.is_nan(self._column))
else:
return (self == cat).fillna(False)
return [encode(cat).astype(dtype) for cat in cats] | def one_hot_encoding(self, cats, dtype='float64'):
"Perform one-hot-encoding\n\n Parameters\n ----------\n cats : sequence of values\n values representing each category.\n dtype : numpy.dtype\n specifies the output dtype.\n\n Returns\n -------\n Sequence\n A sequence of new series for each category. Its length is\n determined by the length of ``cats``.\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series(['a', 'b', 'c', 'a'])\n >>> s\n 0 a\n 1 b\n 2 c\n 3 a\n dtype: object\n >>> s.one_hot_encoding(['a', 'c', 'b'])\n [0 1.0\n 1 0.0\n 2 0.0\n 3 1.0\n dtype: float64, 0 0.0\n 1 0.0\n 2 1.0\n 3 0.0\n dtype: float64, 0 0.0\n 1 1.0\n 2 0.0\n 3 0.0\n dtype: float64]\n "
if hasattr(cats, 'to_arrow'):
cats = cats.to_pandas()
else:
cats = pd.Series(cats, dtype='object')
dtype = cudf.dtype(dtype)
def encode(cat):
if (cat is None):
if (self.dtype.kind == 'f'):
return self.__class__(libcudf.unary.is_null(self._column))
else:
return self.isnull()
elif (np.issubdtype(type(cat), np.floating) and np.isnan(cat)):
return self.__class__(libcudf.unary.is_nan(self._column))
else:
return (self == cat).fillna(False)
return [encode(cat).astype(dtype) for cat in cats]<|docstring|>Perform one-hot-encoding
Parameters
----------
cats : sequence of values
values representing each category.
dtype : numpy.dtype
specifies the output dtype.
Returns
-------
Sequence
A sequence of new series for each category. Its length is
determined by the length of ``cats``.
Examples
--------
>>> import cudf
>>> s = cudf.Series(['a', 'b', 'c', 'a'])
>>> s
0 a
1 b
2 c
3 a
dtype: object
>>> s.one_hot_encoding(['a', 'c', 'b'])
[0 1.0
1 0.0
2 0.0
3 1.0
dtype: float64, 0 0.0
1 0.0
2 1.0
3 0.0
dtype: float64, 0 0.0
1 1.0
2 0.0
3 0.0
dtype: float64]<|endoftext|> |
8c895b845224bfafc0e3a00bf37faf9110ba273343d048849342055a7628ff90 | def label_encoding(self, cats, dtype=None, na_sentinel=(- 1)):
"Perform label encoding\n\n Parameters\n ----------\n values : sequence of input values\n dtype : numpy.dtype; optional\n Specifies the output dtype. If `None` is given, the\n smallest possible integer dtype (starting with np.int8)\n is used.\n na_sentinel : number, default -1\n Value to indicate missing category.\n\n Returns\n -------\n A sequence of encoded labels with value between 0 and n-1 classes(cats)\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 2, 3, 4, 10])\n >>> s.label_encoding([2, 3])\n 0 -1\n 1 0\n 2 1\n 3 -1\n 4 -1\n dtype: int8\n\n `na_sentinel` parameter can be used to\n control the value when there is no encoding.\n\n >>> s.label_encoding([2, 3], na_sentinel=10)\n 0 10\n 1 0\n 2 1\n 3 10\n 4 10\n dtype: int8\n\n When none of `cats` values exist in s, entire\n Series will be `na_sentinel`.\n\n >>> s.label_encoding(['a', 'b', 'c'])\n 0 -1\n 1 -1\n 2 -1\n 3 -1\n 4 -1\n dtype: int8\n "
def _return_sentinel_series():
return Series(cudf.core.column.full(size=len(self), fill_value=na_sentinel, dtype=dtype), index=self.index, name=None)
if (dtype is None):
dtype = min_scalar_type(max(len(cats), na_sentinel), 8)
cats = column.as_column(cats)
if is_mixed_with_object_dtype(self, cats):
return _return_sentinel_series()
try:
cats = cats.astype(self.dtype)
except ValueError:
return _return_sentinel_series()
order = column.arange(len(self))
codes = column.arange(len(cats), dtype=dtype)
value = cudf.DataFrame({'value': cats, 'code': codes})
codes = cudf.DataFrame({'value': self._data.columns[0].copy(deep=False), 'order': order})
codes = codes.merge(value, on='value', how='left')
codes = codes.sort_values('order')['code'].fillna(na_sentinel)
codes.name = None
codes.index = self._index
return codes | Perform label encoding
Parameters
----------
values : sequence of input values
dtype : numpy.dtype; optional
Specifies the output dtype. If `None` is given, the
smallest possible integer dtype (starting with np.int8)
is used.
na_sentinel : number, default -1
Value to indicate missing category.
Returns
-------
A sequence of encoded labels with value between 0 and n-1 classes(cats)
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 2, 3, 4, 10])
>>> s.label_encoding([2, 3])
0 -1
1 0
2 1
3 -1
4 -1
dtype: int8
`na_sentinel` parameter can be used to
control the value when there is no encoding.
>>> s.label_encoding([2, 3], na_sentinel=10)
0 10
1 0
2 1
3 10
4 10
dtype: int8
When none of `cats` values exist in s, entire
Series will be `na_sentinel`.
>>> s.label_encoding(['a', 'b', 'c'])
0 -1
1 -1
2 -1
3 -1
4 -1
dtype: int8 | python/cudf/cudf/core/series.py | label_encoding | jdye64/cudf | 1 | python | def label_encoding(self, cats, dtype=None, na_sentinel=(- 1)):
"Perform label encoding\n\n Parameters\n ----------\n values : sequence of input values\n dtype : numpy.dtype; optional\n Specifies the output dtype. If `None` is given, the\n smallest possible integer dtype (starting with np.int8)\n is used.\n na_sentinel : number, default -1\n Value to indicate missing category.\n\n Returns\n -------\n A sequence of encoded labels with value between 0 and n-1 classes(cats)\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 2, 3, 4, 10])\n >>> s.label_encoding([2, 3])\n 0 -1\n 1 0\n 2 1\n 3 -1\n 4 -1\n dtype: int8\n\n `na_sentinel` parameter can be used to\n control the value when there is no encoding.\n\n >>> s.label_encoding([2, 3], na_sentinel=10)\n 0 10\n 1 0\n 2 1\n 3 10\n 4 10\n dtype: int8\n\n When none of `cats` values exist in s, entire\n Series will be `na_sentinel`.\n\n >>> s.label_encoding(['a', 'b', 'c'])\n 0 -1\n 1 -1\n 2 -1\n 3 -1\n 4 -1\n dtype: int8\n "
def _return_sentinel_series():
return Series(cudf.core.column.full(size=len(self), fill_value=na_sentinel, dtype=dtype), index=self.index, name=None)
if (dtype is None):
dtype = min_scalar_type(max(len(cats), na_sentinel), 8)
cats = column.as_column(cats)
if is_mixed_with_object_dtype(self, cats):
return _return_sentinel_series()
try:
cats = cats.astype(self.dtype)
except ValueError:
return _return_sentinel_series()
order = column.arange(len(self))
codes = column.arange(len(cats), dtype=dtype)
value = cudf.DataFrame({'value': cats, 'code': codes})
codes = cudf.DataFrame({'value': self._data.columns[0].copy(deep=False), 'order': order})
codes = codes.merge(value, on='value', how='left')
codes = codes.sort_values('order')['code'].fillna(na_sentinel)
codes.name = None
codes.index = self._index
return codes | def label_encoding(self, cats, dtype=None, na_sentinel=(- 1)):
"Perform label encoding\n\n Parameters\n ----------\n values : sequence of input values\n dtype : numpy.dtype; optional\n Specifies the output dtype. If `None` is given, the\n smallest possible integer dtype (starting with np.int8)\n is used.\n na_sentinel : number, default -1\n Value to indicate missing category.\n\n Returns\n -------\n A sequence of encoded labels with value between 0 and n-1 classes(cats)\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 2, 3, 4, 10])\n >>> s.label_encoding([2, 3])\n 0 -1\n 1 0\n 2 1\n 3 -1\n 4 -1\n dtype: int8\n\n `na_sentinel` parameter can be used to\n control the value when there is no encoding.\n\n >>> s.label_encoding([2, 3], na_sentinel=10)\n 0 10\n 1 0\n 2 1\n 3 10\n 4 10\n dtype: int8\n\n When none of `cats` values exist in s, entire\n Series will be `na_sentinel`.\n\n >>> s.label_encoding(['a', 'b', 'c'])\n 0 -1\n 1 -1\n 2 -1\n 3 -1\n 4 -1\n dtype: int8\n "
def _return_sentinel_series():
return Series(cudf.core.column.full(size=len(self), fill_value=na_sentinel, dtype=dtype), index=self.index, name=None)
if (dtype is None):
dtype = min_scalar_type(max(len(cats), na_sentinel), 8)
cats = column.as_column(cats)
if is_mixed_with_object_dtype(self, cats):
return _return_sentinel_series()
try:
cats = cats.astype(self.dtype)
except ValueError:
return _return_sentinel_series()
order = column.arange(len(self))
codes = column.arange(len(cats), dtype=dtype)
value = cudf.DataFrame({'value': cats, 'code': codes})
codes = cudf.DataFrame({'value': self._data.columns[0].copy(deep=False), 'order': order})
codes = codes.merge(value, on='value', how='left')
codes = codes.sort_values('order')['code'].fillna(na_sentinel)
codes.name = None
codes.index = self._index
return codes<|docstring|>Perform label encoding
Parameters
----------
values : sequence of input values
dtype : numpy.dtype; optional
Specifies the output dtype. If `None` is given, the
smallest possible integer dtype (starting with np.int8)
is used.
na_sentinel : number, default -1
Value to indicate missing category.
Returns
-------
A sequence of encoded labels with value between 0 and n-1 classes(cats)
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 2, 3, 4, 10])
>>> s.label_encoding([2, 3])
0 -1
1 0
2 1
3 -1
4 -1
dtype: int8
`na_sentinel` parameter can be used to
control the value when there is no encoding.
>>> s.label_encoding([2, 3], na_sentinel=10)
0 10
1 0
2 1
3 10
4 10
dtype: int8
When none of `cats` values exist in s, entire
Series will be `na_sentinel`.
>>> s.label_encoding(['a', 'b', 'c'])
0 -1
1 -1
2 -1
3 -1
4 -1
dtype: int8<|endoftext|> |
66cfffeb95592c9915f75652f4d86d01e8c0342c6989903c37c7d3f63123d968 | def applymap(self, udf, out_dtype=None):
'Apply an elementwise function to transform the values in the Column.\n\n The user function is expected to take one argument and return the\n result, which will be stored to the output Series. The function\n cannot reference globals except for other simple scalar objects.\n\n Parameters\n ----------\n udf : function\n Either a callable python function or a python function already\n decorated by ``numba.cuda.jit`` for call on the GPU as a device\n\n out_dtype : numpy.dtype; optional\n The dtype for use in the output.\n Only used for ``numba.cuda.jit`` decorated udf.\n By default, the result will have the same dtype as the source.\n\n Returns\n -------\n result : Series\n The mask and index are preserved.\n\n Notes\n -----\n The supported Python features are listed in\n\n https://numba.pydata.org/numba-doc/dev/cuda/cudapysupported.html\n\n with these exceptions:\n\n * Math functions in `cmath` are not supported since `libcudf` does not\n have complex number support and output of `cmath` functions are most\n likely complex numbers.\n\n * These five functions in `math` are not supported since numba\n generates multiple PTX functions from them\n\n * math.sin()\n * math.cos()\n * math.tan()\n * math.gamma()\n * math.lgamma()\n\n * Series with string dtypes are not supported in `applymap` method.\n\n * Global variables need to be re-defined explicitly inside\n the udf, as numba considers them to be compile-time constants\n and there is no known way to obtain value of the global variable.\n\n Examples\n --------\n Returning a Series of booleans using only a literal pattern.\n\n >>> import cudf\n >>> s = cudf.Series([1, 10, -10, 200, 100])\n >>> s.applymap(lambda x: x)\n 0 1\n 1 10\n 2 -10\n 3 200\n 4 100\n dtype: int64\n >>> s.applymap(lambda x: x in [1, 100, 59])\n 0 True\n 1 False\n 2 False\n 3 False\n 4 True\n dtype: bool\n >>> s.applymap(lambda x: x ** 2)\n 0 1\n 1 100\n 2 100\n 3 40000\n 4 10000\n dtype: int64\n >>> s.applymap(lambda x: (x ** 2) + (x / 2))\n 0 1.5\n 1 105.0\n 2 95.0\n 3 40100.0\n 4 10050.0\n dtype: float64\n >>> def cube_function(a):\n ... return a ** 3\n ...\n >>> s.applymap(cube_function)\n 0 1\n 1 1000\n 2 -1000\n 3 8000000\n 4 1000000\n dtype: int64\n >>> def custom_udf(x):\n ... if x > 0:\n ... return x + 5\n ... else:\n ... return x - 5\n ...\n >>> s.applymap(custom_udf)\n 0 6\n 1 15\n 2 -15\n 3 205\n 4 105\n dtype: int64\n '
if (not callable(udf)):
raise ValueError('Input UDF must be a callable object.')
return self._from_data({self.name: self._unaryop(udf)}, self._index) | Apply an elementwise function to transform the values in the Column.
The user function is expected to take one argument and return the
result, which will be stored to the output Series. The function
cannot reference globals except for other simple scalar objects.
Parameters
----------
udf : function
Either a callable python function or a python function already
decorated by ``numba.cuda.jit`` for call on the GPU as a device
out_dtype : numpy.dtype; optional
The dtype for use in the output.
Only used for ``numba.cuda.jit`` decorated udf.
By default, the result will have the same dtype as the source.
Returns
-------
result : Series
The mask and index are preserved.
Notes
-----
The supported Python features are listed in
https://numba.pydata.org/numba-doc/dev/cuda/cudapysupported.html
with these exceptions:
* Math functions in `cmath` are not supported since `libcudf` does not
have complex number support and output of `cmath` functions are most
likely complex numbers.
* These five functions in `math` are not supported since numba
generates multiple PTX functions from them
* math.sin()
* math.cos()
* math.tan()
* math.gamma()
* math.lgamma()
* Series with string dtypes are not supported in `applymap` method.
* Global variables need to be re-defined explicitly inside
the udf, as numba considers them to be compile-time constants
and there is no known way to obtain value of the global variable.
Examples
--------
Returning a Series of booleans using only a literal pattern.
>>> import cudf
>>> s = cudf.Series([1, 10, -10, 200, 100])
>>> s.applymap(lambda x: x)
0 1
1 10
2 -10
3 200
4 100
dtype: int64
>>> s.applymap(lambda x: x in [1, 100, 59])
0 True
1 False
2 False
3 False
4 True
dtype: bool
>>> s.applymap(lambda x: x ** 2)
0 1
1 100
2 100
3 40000
4 10000
dtype: int64
>>> s.applymap(lambda x: (x ** 2) + (x / 2))
0 1.5
1 105.0
2 95.0
3 40100.0
4 10050.0
dtype: float64
>>> def cube_function(a):
... return a ** 3
...
>>> s.applymap(cube_function)
0 1
1 1000
2 -1000
3 8000000
4 1000000
dtype: int64
>>> def custom_udf(x):
... if x > 0:
... return x + 5
... else:
... return x - 5
...
>>> s.applymap(custom_udf)
0 6
1 15
2 -15
3 205
4 105
dtype: int64 | python/cudf/cudf/core/series.py | applymap | jdye64/cudf | 1 | python | def applymap(self, udf, out_dtype=None):
'Apply an elementwise function to transform the values in the Column.\n\n The user function is expected to take one argument and return the\n result, which will be stored to the output Series. The function\n cannot reference globals except for other simple scalar objects.\n\n Parameters\n ----------\n udf : function\n Either a callable python function or a python function already\n decorated by ``numba.cuda.jit`` for call on the GPU as a device\n\n out_dtype : numpy.dtype; optional\n The dtype for use in the output.\n Only used for ``numba.cuda.jit`` decorated udf.\n By default, the result will have the same dtype as the source.\n\n Returns\n -------\n result : Series\n The mask and index are preserved.\n\n Notes\n -----\n The supported Python features are listed in\n\n https://numba.pydata.org/numba-doc/dev/cuda/cudapysupported.html\n\n with these exceptions:\n\n * Math functions in `cmath` are not supported since `libcudf` does not\n have complex number support and output of `cmath` functions are most\n likely complex numbers.\n\n * These five functions in `math` are not supported since numba\n generates multiple PTX functions from them\n\n * math.sin()\n * math.cos()\n * math.tan()\n * math.gamma()\n * math.lgamma()\n\n * Series with string dtypes are not supported in `applymap` method.\n\n * Global variables need to be re-defined explicitly inside\n the udf, as numba considers them to be compile-time constants\n and there is no known way to obtain value of the global variable.\n\n Examples\n --------\n Returning a Series of booleans using only a literal pattern.\n\n >>> import cudf\n >>> s = cudf.Series([1, 10, -10, 200, 100])\n >>> s.applymap(lambda x: x)\n 0 1\n 1 10\n 2 -10\n 3 200\n 4 100\n dtype: int64\n >>> s.applymap(lambda x: x in [1, 100, 59])\n 0 True\n 1 False\n 2 False\n 3 False\n 4 True\n dtype: bool\n >>> s.applymap(lambda x: x ** 2)\n 0 1\n 1 100\n 2 100\n 3 40000\n 4 10000\n dtype: int64\n >>> s.applymap(lambda x: (x ** 2) + (x / 2))\n 0 1.5\n 1 105.0\n 2 95.0\n 3 40100.0\n 4 10050.0\n dtype: float64\n >>> def cube_function(a):\n ... return a ** 3\n ...\n >>> s.applymap(cube_function)\n 0 1\n 1 1000\n 2 -1000\n 3 8000000\n 4 1000000\n dtype: int64\n >>> def custom_udf(x):\n ... if x > 0:\n ... return x + 5\n ... else:\n ... return x - 5\n ...\n >>> s.applymap(custom_udf)\n 0 6\n 1 15\n 2 -15\n 3 205\n 4 105\n dtype: int64\n '
if (not callable(udf)):
raise ValueError('Input UDF must be a callable object.')
return self._from_data({self.name: self._unaryop(udf)}, self._index) | def applymap(self, udf, out_dtype=None):
'Apply an elementwise function to transform the values in the Column.\n\n The user function is expected to take one argument and return the\n result, which will be stored to the output Series. The function\n cannot reference globals except for other simple scalar objects.\n\n Parameters\n ----------\n udf : function\n Either a callable python function or a python function already\n decorated by ``numba.cuda.jit`` for call on the GPU as a device\n\n out_dtype : numpy.dtype; optional\n The dtype for use in the output.\n Only used for ``numba.cuda.jit`` decorated udf.\n By default, the result will have the same dtype as the source.\n\n Returns\n -------\n result : Series\n The mask and index are preserved.\n\n Notes\n -----\n The supported Python features are listed in\n\n https://numba.pydata.org/numba-doc/dev/cuda/cudapysupported.html\n\n with these exceptions:\n\n * Math functions in `cmath` are not supported since `libcudf` does not\n have complex number support and output of `cmath` functions are most\n likely complex numbers.\n\n * These five functions in `math` are not supported since numba\n generates multiple PTX functions from them\n\n * math.sin()\n * math.cos()\n * math.tan()\n * math.gamma()\n * math.lgamma()\n\n * Series with string dtypes are not supported in `applymap` method.\n\n * Global variables need to be re-defined explicitly inside\n the udf, as numba considers them to be compile-time constants\n and there is no known way to obtain value of the global variable.\n\n Examples\n --------\n Returning a Series of booleans using only a literal pattern.\n\n >>> import cudf\n >>> s = cudf.Series([1, 10, -10, 200, 100])\n >>> s.applymap(lambda x: x)\n 0 1\n 1 10\n 2 -10\n 3 200\n 4 100\n dtype: int64\n >>> s.applymap(lambda x: x in [1, 100, 59])\n 0 True\n 1 False\n 2 False\n 3 False\n 4 True\n dtype: bool\n >>> s.applymap(lambda x: x ** 2)\n 0 1\n 1 100\n 2 100\n 3 40000\n 4 10000\n dtype: int64\n >>> s.applymap(lambda x: (x ** 2) + (x / 2))\n 0 1.5\n 1 105.0\n 2 95.0\n 3 40100.0\n 4 10050.0\n dtype: float64\n >>> def cube_function(a):\n ... return a ** 3\n ...\n >>> s.applymap(cube_function)\n 0 1\n 1 1000\n 2 -1000\n 3 8000000\n 4 1000000\n dtype: int64\n >>> def custom_udf(x):\n ... if x > 0:\n ... return x + 5\n ... else:\n ... return x - 5\n ...\n >>> s.applymap(custom_udf)\n 0 6\n 1 15\n 2 -15\n 3 205\n 4 105\n dtype: int64\n '
if (not callable(udf)):
raise ValueError('Input UDF must be a callable object.')
return self._from_data({self.name: self._unaryop(udf)}, self._index)<|docstring|>Apply an elementwise function to transform the values in the Column.
The user function is expected to take one argument and return the
result, which will be stored to the output Series. The function
cannot reference globals except for other simple scalar objects.
Parameters
----------
udf : function
Either a callable python function or a python function already
decorated by ``numba.cuda.jit`` for call on the GPU as a device
out_dtype : numpy.dtype; optional
The dtype for use in the output.
Only used for ``numba.cuda.jit`` decorated udf.
By default, the result will have the same dtype as the source.
Returns
-------
result : Series
The mask and index are preserved.
Notes
-----
The supported Python features are listed in
https://numba.pydata.org/numba-doc/dev/cuda/cudapysupported.html
with these exceptions:
* Math functions in `cmath` are not supported since `libcudf` does not
have complex number support and output of `cmath` functions are most
likely complex numbers.
* These five functions in `math` are not supported since numba
generates multiple PTX functions from them
* math.sin()
* math.cos()
* math.tan()
* math.gamma()
* math.lgamma()
* Series with string dtypes are not supported in `applymap` method.
* Global variables need to be re-defined explicitly inside
the udf, as numba considers them to be compile-time constants
and there is no known way to obtain value of the global variable.
Examples
--------
Returning a Series of booleans using only a literal pattern.
>>> import cudf
>>> s = cudf.Series([1, 10, -10, 200, 100])
>>> s.applymap(lambda x: x)
0 1
1 10
2 -10
3 200
4 100
dtype: int64
>>> s.applymap(lambda x: x in [1, 100, 59])
0 True
1 False
2 False
3 False
4 True
dtype: bool
>>> s.applymap(lambda x: x ** 2)
0 1
1 100
2 100
3 40000
4 10000
dtype: int64
>>> s.applymap(lambda x: (x ** 2) + (x / 2))
0 1.5
1 105.0
2 95.0
3 40100.0
4 10050.0
dtype: float64
>>> def cube_function(a):
... return a ** 3
...
>>> s.applymap(cube_function)
0 1
1 1000
2 -1000
3 8000000
4 1000000
dtype: int64
>>> def custom_udf(x):
... if x > 0:
... return x + 5
... else:
... return x - 5
...
>>> s.applymap(custom_udf)
0 6
1 15
2 -15
3 205
4 105
dtype: int64<|endoftext|> |
3bacce36da36e3ae0a493fd5b8fec988187294215946dd4596ffb6ecb4c7d3b8 | def count(self, level=None, **kwargs):
'\n Return number of non-NA/null observations in the Series\n\n Returns\n -------\n int\n Number of non-null values in the Series.\n\n Notes\n -----\n Parameters currently not supported is `level`.\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([1, 5, 2, 4, 3])\n >>> ser.count()\n 5\n '
if (level is not None):
raise NotImplementedError('level parameter is not implemented yet')
return self.valid_count | Return number of non-NA/null observations in the Series
Returns
-------
int
Number of non-null values in the Series.
Notes
-----
Parameters currently not supported is `level`.
Examples
--------
>>> import cudf
>>> ser = cudf.Series([1, 5, 2, 4, 3])
>>> ser.count()
5 | python/cudf/cudf/core/series.py | count | jdye64/cudf | 1 | python | def count(self, level=None, **kwargs):
'\n Return number of non-NA/null observations in the Series\n\n Returns\n -------\n int\n Number of non-null values in the Series.\n\n Notes\n -----\n Parameters currently not supported is `level`.\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([1, 5, 2, 4, 3])\n >>> ser.count()\n 5\n '
if (level is not None):
raise NotImplementedError('level parameter is not implemented yet')
return self.valid_count | def count(self, level=None, **kwargs):
'\n Return number of non-NA/null observations in the Series\n\n Returns\n -------\n int\n Number of non-null values in the Series.\n\n Notes\n -----\n Parameters currently not supported is `level`.\n\n Examples\n --------\n >>> import cudf\n >>> ser = cudf.Series([1, 5, 2, 4, 3])\n >>> ser.count()\n 5\n '
if (level is not None):
raise NotImplementedError('level parameter is not implemented yet')
return self.valid_count<|docstring|>Return number of non-NA/null observations in the Series
Returns
-------
int
Number of non-null values in the Series.
Notes
-----
Parameters currently not supported is `level`.
Examples
--------
>>> import cudf
>>> ser = cudf.Series([1, 5, 2, 4, 3])
>>> ser.count()
5<|endoftext|> |
4e4c0d6ec0700a8cb3bb134823d92c6a99d20f89d05c260734565cf4033b816b | def mode(self, dropna=True):
"\n Return the mode(s) of the dataset.\n\n Always returns Series even if only one value is returned.\n\n Parameters\n ----------\n dropna : bool, default True\n Don't consider counts of NA/NaN/NaT.\n\n Returns\n -------\n Series\n Modes of the Series in sorted order.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([7, 6, 5, 4, 3, 2, 1])\n >>> series\n 0 7\n 1 6\n 2 5\n 3 4\n 4 3\n 5 2\n 6 1\n dtype: int64\n >>> series.mode()\n 0 1\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 6 7\n dtype: int64\n\n We can include ``<NA>`` values in mode by\n passing ``dropna=False``.\n\n >>> series = cudf.Series([7, 4, 3, 3, 7, None, None])\n >>> series\n 0 7\n 1 4\n 2 3\n 3 3\n 4 7\n 5 <NA>\n 6 <NA>\n dtype: int64\n >>> series.mode()\n 0 3\n 1 7\n dtype: int64\n >>> series.mode(dropna=False)\n 0 3\n 1 7\n 2 <NA>\n dtype: int64\n "
val_counts = self.value_counts(ascending=False, dropna=dropna)
if (len(val_counts) > 0):
val_counts = val_counts[(val_counts == val_counts.iloc[0])]
return Series(val_counts.index.sort_values(), name=self.name) | Return the mode(s) of the dataset.
Always returns Series even if only one value is returned.
Parameters
----------
dropna : bool, default True
Don't consider counts of NA/NaN/NaT.
Returns
-------
Series
Modes of the Series in sorted order.
Examples
--------
>>> import cudf
>>> series = cudf.Series([7, 6, 5, 4, 3, 2, 1])
>>> series
0 7
1 6
2 5
3 4
4 3
5 2
6 1
dtype: int64
>>> series.mode()
0 1
1 2
2 3
3 4
4 5
5 6
6 7
dtype: int64
We can include ``<NA>`` values in mode by
passing ``dropna=False``.
>>> series = cudf.Series([7, 4, 3, 3, 7, None, None])
>>> series
0 7
1 4
2 3
3 3
4 7
5 <NA>
6 <NA>
dtype: int64
>>> series.mode()
0 3
1 7
dtype: int64
>>> series.mode(dropna=False)
0 3
1 7
2 <NA>
dtype: int64 | python/cudf/cudf/core/series.py | mode | jdye64/cudf | 1 | python | def mode(self, dropna=True):
"\n Return the mode(s) of the dataset.\n\n Always returns Series even if only one value is returned.\n\n Parameters\n ----------\n dropna : bool, default True\n Don't consider counts of NA/NaN/NaT.\n\n Returns\n -------\n Series\n Modes of the Series in sorted order.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([7, 6, 5, 4, 3, 2, 1])\n >>> series\n 0 7\n 1 6\n 2 5\n 3 4\n 4 3\n 5 2\n 6 1\n dtype: int64\n >>> series.mode()\n 0 1\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 6 7\n dtype: int64\n\n We can include ``<NA>`` values in mode by\n passing ``dropna=False``.\n\n >>> series = cudf.Series([7, 4, 3, 3, 7, None, None])\n >>> series\n 0 7\n 1 4\n 2 3\n 3 3\n 4 7\n 5 <NA>\n 6 <NA>\n dtype: int64\n >>> series.mode()\n 0 3\n 1 7\n dtype: int64\n >>> series.mode(dropna=False)\n 0 3\n 1 7\n 2 <NA>\n dtype: int64\n "
val_counts = self.value_counts(ascending=False, dropna=dropna)
if (len(val_counts) > 0):
val_counts = val_counts[(val_counts == val_counts.iloc[0])]
return Series(val_counts.index.sort_values(), name=self.name) | def mode(self, dropna=True):
"\n Return the mode(s) of the dataset.\n\n Always returns Series even if only one value is returned.\n\n Parameters\n ----------\n dropna : bool, default True\n Don't consider counts of NA/NaN/NaT.\n\n Returns\n -------\n Series\n Modes of the Series in sorted order.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([7, 6, 5, 4, 3, 2, 1])\n >>> series\n 0 7\n 1 6\n 2 5\n 3 4\n 4 3\n 5 2\n 6 1\n dtype: int64\n >>> series.mode()\n 0 1\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 6 7\n dtype: int64\n\n We can include ``<NA>`` values in mode by\n passing ``dropna=False``.\n\n >>> series = cudf.Series([7, 4, 3, 3, 7, None, None])\n >>> series\n 0 7\n 1 4\n 2 3\n 3 3\n 4 7\n 5 <NA>\n 6 <NA>\n dtype: int64\n >>> series.mode()\n 0 3\n 1 7\n dtype: int64\n >>> series.mode(dropna=False)\n 0 3\n 1 7\n 2 <NA>\n dtype: int64\n "
val_counts = self.value_counts(ascending=False, dropna=dropna)
if (len(val_counts) > 0):
val_counts = val_counts[(val_counts == val_counts.iloc[0])]
return Series(val_counts.index.sort_values(), name=self.name)<|docstring|>Return the mode(s) of the dataset.
Always returns Series even if only one value is returned.
Parameters
----------
dropna : bool, default True
Don't consider counts of NA/NaN/NaT.
Returns
-------
Series
Modes of the Series in sorted order.
Examples
--------
>>> import cudf
>>> series = cudf.Series([7, 6, 5, 4, 3, 2, 1])
>>> series
0 7
1 6
2 5
3 4
4 3
5 2
6 1
dtype: int64
>>> series.mode()
0 1
1 2
2 3
3 4
4 5
5 6
6 7
dtype: int64
We can include ``<NA>`` values in mode by
passing ``dropna=False``.
>>> series = cudf.Series([7, 4, 3, 3, 7, None, None])
>>> series
0 7
1 4
2 3
3 3
4 7
5 <NA>
6 <NA>
dtype: int64
>>> series.mode()
0 3
1 7
dtype: int64
>>> series.mode(dropna=False)
0 3
1 7
2 <NA>
dtype: int64<|endoftext|> |
d6a73a2795c61e3d556e7955dc5c266f8816797b182818a3b69c9f1d6d54a951 | def round(self, decimals=0, how='half_even'):
'\n Round each value in a Series to the given number of decimals.\n\n Parameters\n ----------\n decimals : int, default 0\n Number of decimal places to round to. If decimals is negative,\n it specifies the number of positions to the left of the decimal\n point.\n how : str, optional\n Type of rounding. Can be either "half_even" (default)\n of "half_up" rounding.\n\n Returns\n -------\n Series\n Rounded values of the Series.\n\n Examples\n --------\n >>> s = cudf.Series([0.1, 1.4, 2.9])\n >>> s.round()\n 0 0.0\n 1 1.0\n 2 3.0\n dtype: float64\n '
return Series(self._column.round(decimals=decimals, how=how), name=self.name, index=self.index, dtype=self.dtype) | Round each value in a Series to the given number of decimals.
Parameters
----------
decimals : int, default 0
Number of decimal places to round to. If decimals is negative,
it specifies the number of positions to the left of the decimal
point.
how : str, optional
Type of rounding. Can be either "half_even" (default)
of "half_up" rounding.
Returns
-------
Series
Rounded values of the Series.
Examples
--------
>>> s = cudf.Series([0.1, 1.4, 2.9])
>>> s.round()
0 0.0
1 1.0
2 3.0
dtype: float64 | python/cudf/cudf/core/series.py | round | jdye64/cudf | 1 | python | def round(self, decimals=0, how='half_even'):
'\n Round each value in a Series to the given number of decimals.\n\n Parameters\n ----------\n decimals : int, default 0\n Number of decimal places to round to. If decimals is negative,\n it specifies the number of positions to the left of the decimal\n point.\n how : str, optional\n Type of rounding. Can be either "half_even" (default)\n of "half_up" rounding.\n\n Returns\n -------\n Series\n Rounded values of the Series.\n\n Examples\n --------\n >>> s = cudf.Series([0.1, 1.4, 2.9])\n >>> s.round()\n 0 0.0\n 1 1.0\n 2 3.0\n dtype: float64\n '
return Series(self._column.round(decimals=decimals, how=how), name=self.name, index=self.index, dtype=self.dtype) | def round(self, decimals=0, how='half_even'):
'\n Round each value in a Series to the given number of decimals.\n\n Parameters\n ----------\n decimals : int, default 0\n Number of decimal places to round to. If decimals is negative,\n it specifies the number of positions to the left of the decimal\n point.\n how : str, optional\n Type of rounding. Can be either "half_even" (default)\n of "half_up" rounding.\n\n Returns\n -------\n Series\n Rounded values of the Series.\n\n Examples\n --------\n >>> s = cudf.Series([0.1, 1.4, 2.9])\n >>> s.round()\n 0 0.0\n 1 1.0\n 2 3.0\n dtype: float64\n '
return Series(self._column.round(decimals=decimals, how=how), name=self.name, index=self.index, dtype=self.dtype)<|docstring|>Round each value in a Series to the given number of decimals.
Parameters
----------
decimals : int, default 0
Number of decimal places to round to. If decimals is negative,
it specifies the number of positions to the left of the decimal
point.
how : str, optional
Type of rounding. Can be either "half_even" (default)
of "half_up" rounding.
Returns
-------
Series
Rounded values of the Series.
Examples
--------
>>> s = cudf.Series([0.1, 1.4, 2.9])
>>> s.round()
0 0.0
1 1.0
2 3.0
dtype: float64<|endoftext|> |
ce5bf2264c340a999fa7a7bee8bcbfa709977e1602ea6a12594cb28faa3d0847 | def cov(self, other, min_periods=None):
'\n Compute covariance with Series, excluding missing values.\n\n Parameters\n ----------\n other : Series\n Series with which to compute the covariance.\n\n Returns\n -------\n float\n Covariance between Series and other normalized by N-1\n (unbiased estimator).\n\n Notes\n -----\n `min_periods` parameter is not yet supported.\n\n Examples\n --------\n >>> import cudf\n >>> ser1 = cudf.Series([0.9, 0.13, 0.62])\n >>> ser2 = cudf.Series([0.12, 0.26, 0.51])\n >>> ser1.cov(ser2)\n -0.015750000000000004\n '
if (min_periods is not None):
raise NotImplementedError('min_periods parameter is not implemented yet')
if (self.empty or other.empty):
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)
lhs = self.nans_to_nulls().dropna()
rhs = other.nans_to_nulls().dropna()
(lhs, rhs) = _align_indices([lhs, rhs], how='inner')
return lhs._column.cov(rhs._column) | Compute covariance with Series, excluding missing values.
Parameters
----------
other : Series
Series with which to compute the covariance.
Returns
-------
float
Covariance between Series and other normalized by N-1
(unbiased estimator).
Notes
-----
`min_periods` parameter is not yet supported.
Examples
--------
>>> import cudf
>>> ser1 = cudf.Series([0.9, 0.13, 0.62])
>>> ser2 = cudf.Series([0.12, 0.26, 0.51])
>>> ser1.cov(ser2)
-0.015750000000000004 | python/cudf/cudf/core/series.py | cov | jdye64/cudf | 1 | python | def cov(self, other, min_periods=None):
'\n Compute covariance with Series, excluding missing values.\n\n Parameters\n ----------\n other : Series\n Series with which to compute the covariance.\n\n Returns\n -------\n float\n Covariance between Series and other normalized by N-1\n (unbiased estimator).\n\n Notes\n -----\n `min_periods` parameter is not yet supported.\n\n Examples\n --------\n >>> import cudf\n >>> ser1 = cudf.Series([0.9, 0.13, 0.62])\n >>> ser2 = cudf.Series([0.12, 0.26, 0.51])\n >>> ser1.cov(ser2)\n -0.015750000000000004\n '
if (min_periods is not None):
raise NotImplementedError('min_periods parameter is not implemented yet')
if (self.empty or other.empty):
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)
lhs = self.nans_to_nulls().dropna()
rhs = other.nans_to_nulls().dropna()
(lhs, rhs) = _align_indices([lhs, rhs], how='inner')
return lhs._column.cov(rhs._column) | def cov(self, other, min_periods=None):
'\n Compute covariance with Series, excluding missing values.\n\n Parameters\n ----------\n other : Series\n Series with which to compute the covariance.\n\n Returns\n -------\n float\n Covariance between Series and other normalized by N-1\n (unbiased estimator).\n\n Notes\n -----\n `min_periods` parameter is not yet supported.\n\n Examples\n --------\n >>> import cudf\n >>> ser1 = cudf.Series([0.9, 0.13, 0.62])\n >>> ser2 = cudf.Series([0.12, 0.26, 0.51])\n >>> ser1.cov(ser2)\n -0.015750000000000004\n '
if (min_periods is not None):
raise NotImplementedError('min_periods parameter is not implemented yet')
if (self.empty or other.empty):
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)
lhs = self.nans_to_nulls().dropna()
rhs = other.nans_to_nulls().dropna()
(lhs, rhs) = _align_indices([lhs, rhs], how='inner')
return lhs._column.cov(rhs._column)<|docstring|>Compute covariance with Series, excluding missing values.
Parameters
----------
other : Series
Series with which to compute the covariance.
Returns
-------
float
Covariance between Series and other normalized by N-1
(unbiased estimator).
Notes
-----
`min_periods` parameter is not yet supported.
Examples
--------
>>> import cudf
>>> ser1 = cudf.Series([0.9, 0.13, 0.62])
>>> ser2 = cudf.Series([0.12, 0.26, 0.51])
>>> ser1.cov(ser2)
-0.015750000000000004<|endoftext|> |
fdb9d67603a8ec5d23f3807b550c74831f8c38613c81e36541f63aacc3b9cd83 | def corr(self, other, method='pearson', min_periods=None):
'Calculates the sample correlation between two Series,\n excluding missing values.\n\n Examples\n --------\n >>> import cudf\n >>> ser1 = cudf.Series([0.9, 0.13, 0.62])\n >>> ser2 = cudf.Series([0.12, 0.26, 0.51])\n >>> ser1.corr(ser2)\n -0.20454263717316112\n '
if (method not in ('pearson',)):
raise ValueError(f'Unknown method {method}')
if (min_periods not in (None,)):
raise NotImplementedError("Unsupported argument 'min_periods'")
if (self.empty or other.empty):
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)
lhs = self.nans_to_nulls().dropna()
rhs = other.nans_to_nulls().dropna()
(lhs, rhs) = _align_indices([lhs, rhs], how='inner')
return lhs._column.corr(rhs._column) | Calculates the sample correlation between two Series,
excluding missing values.
Examples
--------
>>> import cudf
>>> ser1 = cudf.Series([0.9, 0.13, 0.62])
>>> ser2 = cudf.Series([0.12, 0.26, 0.51])
>>> ser1.corr(ser2)
-0.20454263717316112 | python/cudf/cudf/core/series.py | corr | jdye64/cudf | 1 | python | def corr(self, other, method='pearson', min_periods=None):
'Calculates the sample correlation between two Series,\n excluding missing values.\n\n Examples\n --------\n >>> import cudf\n >>> ser1 = cudf.Series([0.9, 0.13, 0.62])\n >>> ser2 = cudf.Series([0.12, 0.26, 0.51])\n >>> ser1.corr(ser2)\n -0.20454263717316112\n '
if (method not in ('pearson',)):
raise ValueError(f'Unknown method {method}')
if (min_periods not in (None,)):
raise NotImplementedError("Unsupported argument 'min_periods'")
if (self.empty or other.empty):
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)
lhs = self.nans_to_nulls().dropna()
rhs = other.nans_to_nulls().dropna()
(lhs, rhs) = _align_indices([lhs, rhs], how='inner')
return lhs._column.corr(rhs._column) | def corr(self, other, method='pearson', min_periods=None):
'Calculates the sample correlation between two Series,\n excluding missing values.\n\n Examples\n --------\n >>> import cudf\n >>> ser1 = cudf.Series([0.9, 0.13, 0.62])\n >>> ser2 = cudf.Series([0.12, 0.26, 0.51])\n >>> ser1.corr(ser2)\n -0.20454263717316112\n '
if (method not in ('pearson',)):
raise ValueError(f'Unknown method {method}')
if (min_periods not in (None,)):
raise NotImplementedError("Unsupported argument 'min_periods'")
if (self.empty or other.empty):
return cudf.utils.dtypes._get_nan_for_dtype(self.dtype)
lhs = self.nans_to_nulls().dropna()
rhs = other.nans_to_nulls().dropna()
(lhs, rhs) = _align_indices([lhs, rhs], how='inner')
return lhs._column.corr(rhs._column)<|docstring|>Calculates the sample correlation between two Series,
excluding missing values.
Examples
--------
>>> import cudf
>>> ser1 = cudf.Series([0.9, 0.13, 0.62])
>>> ser2 = cudf.Series([0.12, 0.26, 0.51])
>>> ser1.corr(ser2)
-0.20454263717316112<|endoftext|> |
6317f4246118090150f3f7914ef18c7079776bc75f6b3f545d4c79af49dc4afb | def isin(self, values):
"Check whether values are contained in Series.\n\n Parameters\n ----------\n values : set or list-like\n The sequence of values to test. Passing in a single string will\n raise a TypeError. Instead, turn a single string into a list\n of one element.\n\n Returns\n -------\n result : Series\n Series of booleans indicating if each element is in values.\n\n Raises\n -------\n TypeError\n If values is a string\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama',\n ... 'hippo'], name='animal')\n >>> s.isin(['cow', 'lama'])\n 0 True\n 1 True\n 2 True\n 3 False\n 4 True\n 5 False\n Name: animal, dtype: bool\n\n Passing a single string as ``s.isin('lama')`` will raise an error. Use\n a list of one element instead:\n\n >>> s.isin(['lama'])\n 0 True\n 1 False\n 2 True\n 3 False\n 4 True\n 5 False\n Name: animal, dtype: bool\n\n Strings and integers are distinct and are therefore not comparable:\n\n >>> cudf.Series([1]).isin(['1'])\n 0 False\n dtype: bool\n >>> cudf.Series([1.1]).isin(['1.1'])\n 0 False\n dtype: bool\n "
if is_scalar(values):
raise TypeError(f'only list-like objects are allowed to be passed to isin(), you passed a [{type(values).__name__}]')
return Series(self._column.isin(values), index=self.index, name=self.name) | Check whether values are contained in Series.
Parameters
----------
values : set or list-like
The sequence of values to test. Passing in a single string will
raise a TypeError. Instead, turn a single string into a list
of one element.
Returns
-------
result : Series
Series of booleans indicating if each element is in values.
Raises
-------
TypeError
If values is a string
Examples
--------
>>> import cudf
>>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
... 'hippo'], name='animal')
>>> s.isin(['cow', 'lama'])
0 True
1 True
2 True
3 False
4 True
5 False
Name: animal, dtype: bool
Passing a single string as ``s.isin('lama')`` will raise an error. Use
a list of one element instead:
>>> s.isin(['lama'])
0 True
1 False
2 True
3 False
4 True
5 False
Name: animal, dtype: bool
Strings and integers are distinct and are therefore not comparable:
>>> cudf.Series([1]).isin(['1'])
0 False
dtype: bool
>>> cudf.Series([1.1]).isin(['1.1'])
0 False
dtype: bool | python/cudf/cudf/core/series.py | isin | jdye64/cudf | 1 | python | def isin(self, values):
"Check whether values are contained in Series.\n\n Parameters\n ----------\n values : set or list-like\n The sequence of values to test. Passing in a single string will\n raise a TypeError. Instead, turn a single string into a list\n of one element.\n\n Returns\n -------\n result : Series\n Series of booleans indicating if each element is in values.\n\n Raises\n -------\n TypeError\n If values is a string\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama',\n ... 'hippo'], name='animal')\n >>> s.isin(['cow', 'lama'])\n 0 True\n 1 True\n 2 True\n 3 False\n 4 True\n 5 False\n Name: animal, dtype: bool\n\n Passing a single string as ``s.isin('lama')`` will raise an error. Use\n a list of one element instead:\n\n >>> s.isin(['lama'])\n 0 True\n 1 False\n 2 True\n 3 False\n 4 True\n 5 False\n Name: animal, dtype: bool\n\n Strings and integers are distinct and are therefore not comparable:\n\n >>> cudf.Series([1]).isin(['1'])\n 0 False\n dtype: bool\n >>> cudf.Series([1.1]).isin(['1.1'])\n 0 False\n dtype: bool\n "
if is_scalar(values):
raise TypeError(f'only list-like objects are allowed to be passed to isin(), you passed a [{type(values).__name__}]')
return Series(self._column.isin(values), index=self.index, name=self.name) | def isin(self, values):
"Check whether values are contained in Series.\n\n Parameters\n ----------\n values : set or list-like\n The sequence of values to test. Passing in a single string will\n raise a TypeError. Instead, turn a single string into a list\n of one element.\n\n Returns\n -------\n result : Series\n Series of booleans indicating if each element is in values.\n\n Raises\n -------\n TypeError\n If values is a string\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama',\n ... 'hippo'], name='animal')\n >>> s.isin(['cow', 'lama'])\n 0 True\n 1 True\n 2 True\n 3 False\n 4 True\n 5 False\n Name: animal, dtype: bool\n\n Passing a single string as ``s.isin('lama')`` will raise an error. Use\n a list of one element instead:\n\n >>> s.isin(['lama'])\n 0 True\n 1 False\n 2 True\n 3 False\n 4 True\n 5 False\n Name: animal, dtype: bool\n\n Strings and integers are distinct and are therefore not comparable:\n\n >>> cudf.Series([1]).isin(['1'])\n 0 False\n dtype: bool\n >>> cudf.Series([1.1]).isin(['1.1'])\n 0 False\n dtype: bool\n "
if is_scalar(values):
raise TypeError(f'only list-like objects are allowed to be passed to isin(), you passed a [{type(values).__name__}]')
return Series(self._column.isin(values), index=self.index, name=self.name)<|docstring|>Check whether values are contained in Series.
Parameters
----------
values : set or list-like
The sequence of values to test. Passing in a single string will
raise a TypeError. Instead, turn a single string into a list
of one element.
Returns
-------
result : Series
Series of booleans indicating if each element is in values.
Raises
-------
TypeError
If values is a string
Examples
--------
>>> import cudf
>>> s = cudf.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
... 'hippo'], name='animal')
>>> s.isin(['cow', 'lama'])
0 True
1 True
2 True
3 False
4 True
5 False
Name: animal, dtype: bool
Passing a single string as ``s.isin('lama')`` will raise an error. Use
a list of one element instead:
>>> s.isin(['lama'])
0 True
1 False
2 True
3 False
4 True
5 False
Name: animal, dtype: bool
Strings and integers are distinct and are therefore not comparable:
>>> cudf.Series([1]).isin(['1'])
0 False
dtype: bool
>>> cudf.Series([1.1]).isin(['1.1'])
0 False
dtype: bool<|endoftext|> |
3c97f1d90f088d2302dea77ed3bcf5e638c143dcbf7c30f8f7b5136915dcfefd | def unique(self):
"\n Returns unique values of this Series.\n\n Returns\n -------\n Series\n A series with only the unique values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series(['a', 'a', 'b', None, 'b', None, 'c'])\n >>> series\n 0 a\n 1 a\n 2 b\n 3 <NA>\n 4 b\n 5 <NA>\n 6 c\n dtype: object\n >>> series.unique()\n 0 <NA>\n 1 a\n 2 b\n 3 c\n dtype: object\n "
res = self._column.unique()
return Series(res, name=self.name) | Returns unique values of this Series.
Returns
-------
Series
A series with only the unique values.
Examples
--------
>>> import cudf
>>> series = cudf.Series(['a', 'a', 'b', None, 'b', None, 'c'])
>>> series
0 a
1 a
2 b
3 <NA>
4 b
5 <NA>
6 c
dtype: object
>>> series.unique()
0 <NA>
1 a
2 b
3 c
dtype: object | python/cudf/cudf/core/series.py | unique | jdye64/cudf | 1 | python | def unique(self):
"\n Returns unique values of this Series.\n\n Returns\n -------\n Series\n A series with only the unique values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series(['a', 'a', 'b', None, 'b', None, 'c'])\n >>> series\n 0 a\n 1 a\n 2 b\n 3 <NA>\n 4 b\n 5 <NA>\n 6 c\n dtype: object\n >>> series.unique()\n 0 <NA>\n 1 a\n 2 b\n 3 c\n dtype: object\n "
res = self._column.unique()
return Series(res, name=self.name) | def unique(self):
"\n Returns unique values of this Series.\n\n Returns\n -------\n Series\n A series with only the unique values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series(['a', 'a', 'b', None, 'b', None, 'c'])\n >>> series\n 0 a\n 1 a\n 2 b\n 3 <NA>\n 4 b\n 5 <NA>\n 6 c\n dtype: object\n >>> series.unique()\n 0 <NA>\n 1 a\n 2 b\n 3 c\n dtype: object\n "
res = self._column.unique()
return Series(res, name=self.name)<|docstring|>Returns unique values of this Series.
Returns
-------
Series
A series with only the unique values.
Examples
--------
>>> import cudf
>>> series = cudf.Series(['a', 'a', 'b', None, 'b', None, 'c'])
>>> series
0 a
1 a
2 b
3 <NA>
4 b
5 <NA>
6 c
dtype: object
>>> series.unique()
0 <NA>
1 a
2 b
3 c
dtype: object<|endoftext|> |
f9458bee25d425c1f199eb6a499d2edbfa8b7a61c34152e7b4936f8d73b2bdbc | def nunique(self, method='sort', dropna=True):
"Returns the number of unique values of the Series: approximate version,\n and exact version to be moved to libgdf\n\n Excludes NA values by default.\n\n Parameters\n ----------\n dropna : bool, default True\n Don't include NA values in the count.\n\n Returns\n -------\n int\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 3, 5, 7, 7])\n >>> s\n 0 1\n 1 3\n 2 5\n 3 7\n 4 7\n dtype: int64\n >>> s.nunique()\n 4\n "
if (method != 'sort'):
msg = 'non sort based distinct_count() not implemented yet'
raise NotImplementedError(msg)
if (self.null_count == len(self)):
return 0
return self._column.distinct_count(method, dropna) | Returns the number of unique values of the Series: approximate version,
and exact version to be moved to libgdf
Excludes NA values by default.
Parameters
----------
dropna : bool, default True
Don't include NA values in the count.
Returns
-------
int
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 3, 5, 7, 7])
>>> s
0 1
1 3
2 5
3 7
4 7
dtype: int64
>>> s.nunique()
4 | python/cudf/cudf/core/series.py | nunique | jdye64/cudf | 1 | python | def nunique(self, method='sort', dropna=True):
"Returns the number of unique values of the Series: approximate version,\n and exact version to be moved to libgdf\n\n Excludes NA values by default.\n\n Parameters\n ----------\n dropna : bool, default True\n Don't include NA values in the count.\n\n Returns\n -------\n int\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 3, 5, 7, 7])\n >>> s\n 0 1\n 1 3\n 2 5\n 3 7\n 4 7\n dtype: int64\n >>> s.nunique()\n 4\n "
if (method != 'sort'):
msg = 'non sort based distinct_count() not implemented yet'
raise NotImplementedError(msg)
if (self.null_count == len(self)):
return 0
return self._column.distinct_count(method, dropna) | def nunique(self, method='sort', dropna=True):
"Returns the number of unique values of the Series: approximate version,\n and exact version to be moved to libgdf\n\n Excludes NA values by default.\n\n Parameters\n ----------\n dropna : bool, default True\n Don't include NA values in the count.\n\n Returns\n -------\n int\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([1, 3, 5, 7, 7])\n >>> s\n 0 1\n 1 3\n 2 5\n 3 7\n 4 7\n dtype: int64\n >>> s.nunique()\n 4\n "
if (method != 'sort'):
msg = 'non sort based distinct_count() not implemented yet'
raise NotImplementedError(msg)
if (self.null_count == len(self)):
return 0
return self._column.distinct_count(method, dropna)<|docstring|>Returns the number of unique values of the Series: approximate version,
and exact version to be moved to libgdf
Excludes NA values by default.
Parameters
----------
dropna : bool, default True
Don't include NA values in the count.
Returns
-------
int
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 3, 5, 7, 7])
>>> s
0 1
1 3
2 5
3 7
4 7
dtype: int64
>>> s.nunique()
4<|endoftext|> |
80a6520f8169cd6fedefb216cd38d310326fc7a6604ee637fb9e14cd9504df20 | def value_counts(self, normalize=False, sort=True, ascending=False, bins=None, dropna=True):
'Return a Series containing counts of unique values.\n\n The resulting object will be in descending order so that\n the first element is the most frequently-occurring element.\n Excludes NA values by default.\n\n Parameters\n ----------\n normalize : bool, default False\n If True then the object returned will contain\n the relative frequencies of the unique values.\n\n sort : bool, default True\n Sort by frequencies.\n\n ascending : bool, default False\n Sort in ascending order.\n\n bins : int, optional\n Rather than count values, group them into half-open bins,\n works with numeric data. This Parameter is not yet supported.\n\n dropna : bool, default True\n Don’t include counts of NaN and None.\n\n Returns\n -------\n result : Series contanining counts of unique values.\n\n See also\n --------\n Series.count\n Number of non-NA elements in a Series.\n\n cudf.DataFrame.count\n Number of non-NA elements in a DataFrame.\n\n Examples\n --------\n >>> import cudf\n >>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0, None])\n >>> sr\n 0 1.0\n 1 2.0\n 2 2.0\n 3 3.0\n 4 3.0\n 5 3.0\n 6 <NA>\n dtype: float64\n >>> sr.value_counts()\n 3.0 3\n 2.0 2\n 1.0 1\n dtype: int32\n\n The order of the counts can be changed by passing ``ascending=True``:\n\n >>> sr.value_counts(ascending=True)\n 1.0 1\n 2.0 2\n 3.0 3\n dtype: int32\n\n With ``normalize`` set to True, returns the relative frequency\n by dividing all values by the sum of values.\n\n >>> sr.value_counts(normalize=True)\n 3.0 0.500000\n 2.0 0.333333\n 1.0 0.166667\n dtype: float64\n\n To include ``NA`` value counts, pass ``dropna=False``:\n\n >>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, None, 3.0, 3.0, None])\n >>> sr\n 0 1.0\n 1 2.0\n 2 2.0\n 3 3.0\n 4 <NA>\n 5 3.0\n 6 3.0\n 7 <NA>\n dtype: float64\n >>> sr.value_counts(dropna=False)\n 3.0 3\n 2.0 2\n <NA> 2\n 1.0 1\n dtype: int32\n '
if (bins is not None):
raise NotImplementedError('bins is not yet supported')
if (dropna and (self.null_count == len(self))):
return Series([], dtype=np.int32, name=self.name, index=cudf.Index([], dtype=self.dtype))
res = self.groupby(self, dropna=dropna).count(dropna=dropna)
res.index.name = None
if sort:
res = res.sort_values(ascending=ascending)
if normalize:
res = (res / float(res._column.sum()))
return res | Return a Series containing counts of unique values.
The resulting object will be in descending order so that
the first element is the most frequently-occurring element.
Excludes NA values by default.
Parameters
----------
normalize : bool, default False
If True then the object returned will contain
the relative frequencies of the unique values.
sort : bool, default True
Sort by frequencies.
ascending : bool, default False
Sort in ascending order.
bins : int, optional
Rather than count values, group them into half-open bins,
works with numeric data. This Parameter is not yet supported.
dropna : bool, default True
Don’t include counts of NaN and None.
Returns
-------
result : Series contanining counts of unique values.
See also
--------
Series.count
Number of non-NA elements in a Series.
cudf.DataFrame.count
Number of non-NA elements in a DataFrame.
Examples
--------
>>> import cudf
>>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0, None])
>>> sr
0 1.0
1 2.0
2 2.0
3 3.0
4 3.0
5 3.0
6 <NA>
dtype: float64
>>> sr.value_counts()
3.0 3
2.0 2
1.0 1
dtype: int32
The order of the counts can be changed by passing ``ascending=True``:
>>> sr.value_counts(ascending=True)
1.0 1
2.0 2
3.0 3
dtype: int32
With ``normalize`` set to True, returns the relative frequency
by dividing all values by the sum of values.
>>> sr.value_counts(normalize=True)
3.0 0.500000
2.0 0.333333
1.0 0.166667
dtype: float64
To include ``NA`` value counts, pass ``dropna=False``:
>>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, None, 3.0, 3.0, None])
>>> sr
0 1.0
1 2.0
2 2.0
3 3.0
4 <NA>
5 3.0
6 3.0
7 <NA>
dtype: float64
>>> sr.value_counts(dropna=False)
3.0 3
2.0 2
<NA> 2
1.0 1
dtype: int32 | python/cudf/cudf/core/series.py | value_counts | jdye64/cudf | 1 | python | def value_counts(self, normalize=False, sort=True, ascending=False, bins=None, dropna=True):
'Return a Series containing counts of unique values.\n\n The resulting object will be in descending order so that\n the first element is the most frequently-occurring element.\n Excludes NA values by default.\n\n Parameters\n ----------\n normalize : bool, default False\n If True then the object returned will contain\n the relative frequencies of the unique values.\n\n sort : bool, default True\n Sort by frequencies.\n\n ascending : bool, default False\n Sort in ascending order.\n\n bins : int, optional\n Rather than count values, group them into half-open bins,\n works with numeric data. This Parameter is not yet supported.\n\n dropna : bool, default True\n Don’t include counts of NaN and None.\n\n Returns\n -------\n result : Series contanining counts of unique values.\n\n See also\n --------\n Series.count\n Number of non-NA elements in a Series.\n\n cudf.DataFrame.count\n Number of non-NA elements in a DataFrame.\n\n Examples\n --------\n >>> import cudf\n >>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0, None])\n >>> sr\n 0 1.0\n 1 2.0\n 2 2.0\n 3 3.0\n 4 3.0\n 5 3.0\n 6 <NA>\n dtype: float64\n >>> sr.value_counts()\n 3.0 3\n 2.0 2\n 1.0 1\n dtype: int32\n\n The order of the counts can be changed by passing ``ascending=True``:\n\n >>> sr.value_counts(ascending=True)\n 1.0 1\n 2.0 2\n 3.0 3\n dtype: int32\n\n With ``normalize`` set to True, returns the relative frequency\n by dividing all values by the sum of values.\n\n >>> sr.value_counts(normalize=True)\n 3.0 0.500000\n 2.0 0.333333\n 1.0 0.166667\n dtype: float64\n\n To include ``NA`` value counts, pass ``dropna=False``:\n\n >>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, None, 3.0, 3.0, None])\n >>> sr\n 0 1.0\n 1 2.0\n 2 2.0\n 3 3.0\n 4 <NA>\n 5 3.0\n 6 3.0\n 7 <NA>\n dtype: float64\n >>> sr.value_counts(dropna=False)\n 3.0 3\n 2.0 2\n <NA> 2\n 1.0 1\n dtype: int32\n '
if (bins is not None):
raise NotImplementedError('bins is not yet supported')
if (dropna and (self.null_count == len(self))):
return Series([], dtype=np.int32, name=self.name, index=cudf.Index([], dtype=self.dtype))
res = self.groupby(self, dropna=dropna).count(dropna=dropna)
res.index.name = None
if sort:
res = res.sort_values(ascending=ascending)
if normalize:
res = (res / float(res._column.sum()))
return res | def value_counts(self, normalize=False, sort=True, ascending=False, bins=None, dropna=True):
'Return a Series containing counts of unique values.\n\n The resulting object will be in descending order so that\n the first element is the most frequently-occurring element.\n Excludes NA values by default.\n\n Parameters\n ----------\n normalize : bool, default False\n If True then the object returned will contain\n the relative frequencies of the unique values.\n\n sort : bool, default True\n Sort by frequencies.\n\n ascending : bool, default False\n Sort in ascending order.\n\n bins : int, optional\n Rather than count values, group them into half-open bins,\n works with numeric data. This Parameter is not yet supported.\n\n dropna : bool, default True\n Don’t include counts of NaN and None.\n\n Returns\n -------\n result : Series contanining counts of unique values.\n\n See also\n --------\n Series.count\n Number of non-NA elements in a Series.\n\n cudf.DataFrame.count\n Number of non-NA elements in a DataFrame.\n\n Examples\n --------\n >>> import cudf\n >>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0, None])\n >>> sr\n 0 1.0\n 1 2.0\n 2 2.0\n 3 3.0\n 4 3.0\n 5 3.0\n 6 <NA>\n dtype: float64\n >>> sr.value_counts()\n 3.0 3\n 2.0 2\n 1.0 1\n dtype: int32\n\n The order of the counts can be changed by passing ``ascending=True``:\n\n >>> sr.value_counts(ascending=True)\n 1.0 1\n 2.0 2\n 3.0 3\n dtype: int32\n\n With ``normalize`` set to True, returns the relative frequency\n by dividing all values by the sum of values.\n\n >>> sr.value_counts(normalize=True)\n 3.0 0.500000\n 2.0 0.333333\n 1.0 0.166667\n dtype: float64\n\n To include ``NA`` value counts, pass ``dropna=False``:\n\n >>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, None, 3.0, 3.0, None])\n >>> sr\n 0 1.0\n 1 2.0\n 2 2.0\n 3 3.0\n 4 <NA>\n 5 3.0\n 6 3.0\n 7 <NA>\n dtype: float64\n >>> sr.value_counts(dropna=False)\n 3.0 3\n 2.0 2\n <NA> 2\n 1.0 1\n dtype: int32\n '
if (bins is not None):
raise NotImplementedError('bins is not yet supported')
if (dropna and (self.null_count == len(self))):
return Series([], dtype=np.int32, name=self.name, index=cudf.Index([], dtype=self.dtype))
res = self.groupby(self, dropna=dropna).count(dropna=dropna)
res.index.name = None
if sort:
res = res.sort_values(ascending=ascending)
if normalize:
res = (res / float(res._column.sum()))
return res<|docstring|>Return a Series containing counts of unique values.
The resulting object will be in descending order so that
the first element is the most frequently-occurring element.
Excludes NA values by default.
Parameters
----------
normalize : bool, default False
If True then the object returned will contain
the relative frequencies of the unique values.
sort : bool, default True
Sort by frequencies.
ascending : bool, default False
Sort in ascending order.
bins : int, optional
Rather than count values, group them into half-open bins,
works with numeric data. This Parameter is not yet supported.
dropna : bool, default True
Don’t include counts of NaN and None.
Returns
-------
result : Series contanining counts of unique values.
See also
--------
Series.count
Number of non-NA elements in a Series.
cudf.DataFrame.count
Number of non-NA elements in a DataFrame.
Examples
--------
>>> import cudf
>>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, 3.0, 3.0, None])
>>> sr
0 1.0
1 2.0
2 2.0
3 3.0
4 3.0
5 3.0
6 <NA>
dtype: float64
>>> sr.value_counts()
3.0 3
2.0 2
1.0 1
dtype: int32
The order of the counts can be changed by passing ``ascending=True``:
>>> sr.value_counts(ascending=True)
1.0 1
2.0 2
3.0 3
dtype: int32
With ``normalize`` set to True, returns the relative frequency
by dividing all values by the sum of values.
>>> sr.value_counts(normalize=True)
3.0 0.500000
2.0 0.333333
1.0 0.166667
dtype: float64
To include ``NA`` value counts, pass ``dropna=False``:
>>> sr = cudf.Series([1.0, 2.0, 2.0, 3.0, None, 3.0, 3.0, None])
>>> sr
0 1.0
1 2.0
2 2.0
3 3.0
4 <NA>
5 3.0
6 3.0
7 <NA>
dtype: float64
>>> sr.value_counts(dropna=False)
3.0 3
2.0 2
<NA> 2
1.0 1
dtype: int32<|endoftext|> |
35cad7da5a48e4bfb737cb54a9c43e2c428f0ff485cd429dfe6fa9e9f39de318 | def scale(self):
'\n Scale values to [0, 1] in float64\n\n Returns\n -------\n Series\n A new series with values scaled to [0, 1].\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12, 0.5, 1])\n >>> series\n 0 10.0\n 1 11.0\n 2 12.0\n 3 0.5\n 4 1.0\n dtype: float64\n >>> series.scale()\n 0 0.826087\n 1 0.913043\n 2 1.000000\n 3 0.000000\n 4 0.043478\n dtype: float64\n '
vmin = self.min()
vmax = self.max()
scaled = ((self - vmin) / (vmax - vmin))
scaled._index = self._index.copy(deep=False)
return scaled | Scale values to [0, 1] in float64
Returns
-------
Series
A new series with values scaled to [0, 1].
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 11, 12, 0.5, 1])
>>> series
0 10.0
1 11.0
2 12.0
3 0.5
4 1.0
dtype: float64
>>> series.scale()
0 0.826087
1 0.913043
2 1.000000
3 0.000000
4 0.043478
dtype: float64 | python/cudf/cudf/core/series.py | scale | jdye64/cudf | 1 | python | def scale(self):
'\n Scale values to [0, 1] in float64\n\n Returns\n -------\n Series\n A new series with values scaled to [0, 1].\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12, 0.5, 1])\n >>> series\n 0 10.0\n 1 11.0\n 2 12.0\n 3 0.5\n 4 1.0\n dtype: float64\n >>> series.scale()\n 0 0.826087\n 1 0.913043\n 2 1.000000\n 3 0.000000\n 4 0.043478\n dtype: float64\n '
vmin = self.min()
vmax = self.max()
scaled = ((self - vmin) / (vmax - vmin))
scaled._index = self._index.copy(deep=False)
return scaled | def scale(self):
'\n Scale values to [0, 1] in float64\n\n Returns\n -------\n Series\n A new series with values scaled to [0, 1].\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 11, 12, 0.5, 1])\n >>> series\n 0 10.0\n 1 11.0\n 2 12.0\n 3 0.5\n 4 1.0\n dtype: float64\n >>> series.scale()\n 0 0.826087\n 1 0.913043\n 2 1.000000\n 3 0.000000\n 4 0.043478\n dtype: float64\n '
vmin = self.min()
vmax = self.max()
scaled = ((self - vmin) / (vmax - vmin))
scaled._index = self._index.copy(deep=False)
return scaled<|docstring|>Scale values to [0, 1] in float64
Returns
-------
Series
A new series with values scaled to [0, 1].
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 11, 12, 0.5, 1])
>>> series
0 10.0
1 11.0
2 12.0
3 0.5
4 1.0
dtype: float64
>>> series.scale()
0 0.826087
1 0.913043
2 1.000000
3 0.000000
4 0.043478
dtype: float64<|endoftext|> |
631a4e7fed933812c72ce0d88e6c1cd4222144e1146a452003459d38649025fa | def abs(self):
'Absolute value of each element of the series.\n\n Returns\n -------\n abs\n Series containing the absolute value of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([-1.10, 2, -3.33, 4])\n >>> series\n 0 -1.10\n 1 2.00\n 2 -3.33\n 3 4.00\n dtype: float64\n >>> series.abs()\n 0 1.10\n 1 2.00\n 2 3.33\n 3 4.00\n dtype: float64\n '
return self._unaryop('abs') | Absolute value of each element of the series.
Returns
-------
abs
Series containing the absolute value of each element.
Examples
--------
>>> import cudf
>>> series = cudf.Series([-1.10, 2, -3.33, 4])
>>> series
0 -1.10
1 2.00
2 -3.33
3 4.00
dtype: float64
>>> series.abs()
0 1.10
1 2.00
2 3.33
3 4.00
dtype: float64 | python/cudf/cudf/core/series.py | abs | jdye64/cudf | 1 | python | def abs(self):
'Absolute value of each element of the series.\n\n Returns\n -------\n abs\n Series containing the absolute value of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([-1.10, 2, -3.33, 4])\n >>> series\n 0 -1.10\n 1 2.00\n 2 -3.33\n 3 4.00\n dtype: float64\n >>> series.abs()\n 0 1.10\n 1 2.00\n 2 3.33\n 3 4.00\n dtype: float64\n '
return self._unaryop('abs') | def abs(self):
'Absolute value of each element of the series.\n\n Returns\n -------\n abs\n Series containing the absolute value of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([-1.10, 2, -3.33, 4])\n >>> series\n 0 -1.10\n 1 2.00\n 2 -3.33\n 3 4.00\n dtype: float64\n >>> series.abs()\n 0 1.10\n 1 2.00\n 2 3.33\n 3 4.00\n dtype: float64\n '
return self._unaryop('abs')<|docstring|>Absolute value of each element of the series.
Returns
-------
abs
Series containing the absolute value of each element.
Examples
--------
>>> import cudf
>>> series = cudf.Series([-1.10, 2, -3.33, 4])
>>> series
0 -1.10
1 2.00
2 -3.33
3 4.00
dtype: float64
>>> series.abs()
0 1.10
1 2.00
2 3.33
3 4.00
dtype: float64<|endoftext|> |
c31be17255d518f3ab02b47019f8b1519cbc79ec61e2e41ffaf32fda1766b266 | def ceil(self):
'\n Rounds each value upward to the smallest integral value not less\n than the original.\n\n Returns\n -------\n res\n Returns a new Series with ceiling value of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1.1, 2.8, 3.5, 4.5])\n >>> series\n 0 1.1\n 1 2.8\n 2 3.5\n 3 4.5\n dtype: float64\n >>> series.ceil()\n 0 2.0\n 1 3.0\n 2 4.0\n 3 5.0\n dtype: float64\n '
return self._unaryop('ceil') | Rounds each value upward to the smallest integral value not less
than the original.
Returns
-------
res
Returns a new Series with ceiling value of each element.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1.1, 2.8, 3.5, 4.5])
>>> series
0 1.1
1 2.8
2 3.5
3 4.5
dtype: float64
>>> series.ceil()
0 2.0
1 3.0
2 4.0
3 5.0
dtype: float64 | python/cudf/cudf/core/series.py | ceil | jdye64/cudf | 1 | python | def ceil(self):
'\n Rounds each value upward to the smallest integral value not less\n than the original.\n\n Returns\n -------\n res\n Returns a new Series with ceiling value of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1.1, 2.8, 3.5, 4.5])\n >>> series\n 0 1.1\n 1 2.8\n 2 3.5\n 3 4.5\n dtype: float64\n >>> series.ceil()\n 0 2.0\n 1 3.0\n 2 4.0\n 3 5.0\n dtype: float64\n '
return self._unaryop('ceil') | def ceil(self):
'\n Rounds each value upward to the smallest integral value not less\n than the original.\n\n Returns\n -------\n res\n Returns a new Series with ceiling value of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1.1, 2.8, 3.5, 4.5])\n >>> series\n 0 1.1\n 1 2.8\n 2 3.5\n 3 4.5\n dtype: float64\n >>> series.ceil()\n 0 2.0\n 1 3.0\n 2 4.0\n 3 5.0\n dtype: float64\n '
return self._unaryop('ceil')<|docstring|>Rounds each value upward to the smallest integral value not less
than the original.
Returns
-------
res
Returns a new Series with ceiling value of each element.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1.1, 2.8, 3.5, 4.5])
>>> series
0 1.1
1 2.8
2 3.5
3 4.5
dtype: float64
>>> series.ceil()
0 2.0
1 3.0
2 4.0
3 5.0
dtype: float64<|endoftext|> |
edad64f295c76dd98e6aea642cc7fa6413e73c1706f4f53663be73adbcde68c7 | def floor(self):
'Rounds each value downward to the largest integral value not greater\n than the original.\n\n Returns\n -------\n res\n Returns a new Series with floor of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([-1.9, 2, 0.2, 1.5, 0.0, 3.0])\n >>> series\n 0 -1.9\n 1 2.0\n 2 0.2\n 3 1.5\n 4 0.0\n 5 3.0\n dtype: float64\n >>> series.floor()\n 0 -2.0\n 1 2.0\n 2 0.0\n 3 1.0\n 4 0.0\n 5 3.0\n dtype: float64\n '
return self._unaryop('floor') | Rounds each value downward to the largest integral value not greater
than the original.
Returns
-------
res
Returns a new Series with floor of each element.
Examples
--------
>>> import cudf
>>> series = cudf.Series([-1.9, 2, 0.2, 1.5, 0.0, 3.0])
>>> series
0 -1.9
1 2.0
2 0.2
3 1.5
4 0.0
5 3.0
dtype: float64
>>> series.floor()
0 -2.0
1 2.0
2 0.0
3 1.0
4 0.0
5 3.0
dtype: float64 | python/cudf/cudf/core/series.py | floor | jdye64/cudf | 1 | python | def floor(self):
'Rounds each value downward to the largest integral value not greater\n than the original.\n\n Returns\n -------\n res\n Returns a new Series with floor of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([-1.9, 2, 0.2, 1.5, 0.0, 3.0])\n >>> series\n 0 -1.9\n 1 2.0\n 2 0.2\n 3 1.5\n 4 0.0\n 5 3.0\n dtype: float64\n >>> series.floor()\n 0 -2.0\n 1 2.0\n 2 0.0\n 3 1.0\n 4 0.0\n 5 3.0\n dtype: float64\n '
return self._unaryop('floor') | def floor(self):
'Rounds each value downward to the largest integral value not greater\n than the original.\n\n Returns\n -------\n res\n Returns a new Series with floor of each element.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([-1.9, 2, 0.2, 1.5, 0.0, 3.0])\n >>> series\n 0 -1.9\n 1 2.0\n 2 0.2\n 3 1.5\n 4 0.0\n 5 3.0\n dtype: float64\n >>> series.floor()\n 0 -2.0\n 1 2.0\n 2 0.0\n 3 1.0\n 4 0.0\n 5 3.0\n dtype: float64\n '
return self._unaryop('floor')<|docstring|>Rounds each value downward to the largest integral value not greater
than the original.
Returns
-------
res
Returns a new Series with floor of each element.
Examples
--------
>>> import cudf
>>> series = cudf.Series([-1.9, 2, 0.2, 1.5, 0.0, 3.0])
>>> series
0 -1.9
1 2.0
2 0.2
3 1.5
4 0.0
5 3.0
dtype: float64
>>> series.floor()
0 -2.0
1 2.0
2 0.0
3 1.0
4 0.0
5 3.0
dtype: float64<|endoftext|> |
62fef5e8e218460c0a4238d764d7f4ee198e526657daa3fcfbea087d3cf8282a | def hash_values(self):
'Compute the hash of values in this column.\n\n Returns\n -------\n cupy array\n A cupy array with hash values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 120, 30])\n >>> series\n 0 10\n 1 120\n 2 30\n dtype: int64\n >>> series.hash_values()\n array([-1930516747, 422619251, -941520876], dtype=int32)\n '
return Series(self._hash()).values | Compute the hash of values in this column.
Returns
-------
cupy array
A cupy array with hash values.
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 120, 30])
>>> series
0 10
1 120
2 30
dtype: int64
>>> series.hash_values()
array([-1930516747, 422619251, -941520876], dtype=int32) | python/cudf/cudf/core/series.py | hash_values | jdye64/cudf | 1 | python | def hash_values(self):
'Compute the hash of values in this column.\n\n Returns\n -------\n cupy array\n A cupy array with hash values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 120, 30])\n >>> series\n 0 10\n 1 120\n 2 30\n dtype: int64\n >>> series.hash_values()\n array([-1930516747, 422619251, -941520876], dtype=int32)\n '
return Series(self._hash()).values | def hash_values(self):
'Compute the hash of values in this column.\n\n Returns\n -------\n cupy array\n A cupy array with hash values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 120, 30])\n >>> series\n 0 10\n 1 120\n 2 30\n dtype: int64\n >>> series.hash_values()\n array([-1930516747, 422619251, -941520876], dtype=int32)\n '
return Series(self._hash()).values<|docstring|>Compute the hash of values in this column.
Returns
-------
cupy array
A cupy array with hash values.
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 120, 30])
>>> series
0 10
1 120
2 30
dtype: int64
>>> series.hash_values()
array([-1930516747, 422619251, -941520876], dtype=int32)<|endoftext|> |
65cfbe4f2bed25c536d17f071f16495bd97fd4aee5adc9c42b20c02e01f3e068 | def hash_encode(self, stop, use_name=False):
'Encode column values as ints in [0, stop) using hash function.\n\n Parameters\n ----------\n stop : int\n The upper bound on the encoding range.\n use_name : bool\n If ``True`` then combine hashed column values\n with hashed column name. This is useful for when the same\n values in different columns should be encoded\n with different hashed values.\n\n Returns\n -------\n result : Series\n The encoded Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 120, 30])\n >>> series.hash_encode(stop=200)\n 0 53\n 1 51\n 2 124\n dtype: int32\n\n You can choose to include name while hash\n encoding by specifying `use_name=True`\n\n >>> series.hash_encode(stop=200, use_name=True)\n 0 131\n 1 29\n 2 76\n dtype: int32\n '
if (not (stop > 0)):
raise ValueError('stop must be a positive integer.')
initial_hash = ([(hash(self.name) & 4294967295)] if use_name else None)
hashed_values = Series(self._hash(initial_hash))
if hashed_values.has_nulls:
raise ValueError('Column must have no nulls.')
mod_vals = (hashed_values % stop)
return Series(mod_vals._column, index=self.index, name=self.name) | Encode column values as ints in [0, stop) using hash function.
Parameters
----------
stop : int
The upper bound on the encoding range.
use_name : bool
If ``True`` then combine hashed column values
with hashed column name. This is useful for when the same
values in different columns should be encoded
with different hashed values.
Returns
-------
result : Series
The encoded Series.
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 120, 30])
>>> series.hash_encode(stop=200)
0 53
1 51
2 124
dtype: int32
You can choose to include name while hash
encoding by specifying `use_name=True`
>>> series.hash_encode(stop=200, use_name=True)
0 131
1 29
2 76
dtype: int32 | python/cudf/cudf/core/series.py | hash_encode | jdye64/cudf | 1 | python | def hash_encode(self, stop, use_name=False):
'Encode column values as ints in [0, stop) using hash function.\n\n Parameters\n ----------\n stop : int\n The upper bound on the encoding range.\n use_name : bool\n If ``True`` then combine hashed column values\n with hashed column name. This is useful for when the same\n values in different columns should be encoded\n with different hashed values.\n\n Returns\n -------\n result : Series\n The encoded Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 120, 30])\n >>> series.hash_encode(stop=200)\n 0 53\n 1 51\n 2 124\n dtype: int32\n\n You can choose to include name while hash\n encoding by specifying `use_name=True`\n\n >>> series.hash_encode(stop=200, use_name=True)\n 0 131\n 1 29\n 2 76\n dtype: int32\n '
if (not (stop > 0)):
raise ValueError('stop must be a positive integer.')
initial_hash = ([(hash(self.name) & 4294967295)] if use_name else None)
hashed_values = Series(self._hash(initial_hash))
if hashed_values.has_nulls:
raise ValueError('Column must have no nulls.')
mod_vals = (hashed_values % stop)
return Series(mod_vals._column, index=self.index, name=self.name) | def hash_encode(self, stop, use_name=False):
'Encode column values as ints in [0, stop) using hash function.\n\n Parameters\n ----------\n stop : int\n The upper bound on the encoding range.\n use_name : bool\n If ``True`` then combine hashed column values\n with hashed column name. This is useful for when the same\n values in different columns should be encoded\n with different hashed values.\n\n Returns\n -------\n result : Series\n The encoded Series.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 120, 30])\n >>> series.hash_encode(stop=200)\n 0 53\n 1 51\n 2 124\n dtype: int32\n\n You can choose to include name while hash\n encoding by specifying `use_name=True`\n\n >>> series.hash_encode(stop=200, use_name=True)\n 0 131\n 1 29\n 2 76\n dtype: int32\n '
if (not (stop > 0)):
raise ValueError('stop must be a positive integer.')
initial_hash = ([(hash(self.name) & 4294967295)] if use_name else None)
hashed_values = Series(self._hash(initial_hash))
if hashed_values.has_nulls:
raise ValueError('Column must have no nulls.')
mod_vals = (hashed_values % stop)
return Series(mod_vals._column, index=self.index, name=self.name)<|docstring|>Encode column values as ints in [0, stop) using hash function.
Parameters
----------
stop : int
The upper bound on the encoding range.
use_name : bool
If ``True`` then combine hashed column values
with hashed column name. This is useful for when the same
values in different columns should be encoded
with different hashed values.
Returns
-------
result : Series
The encoded Series.
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 120, 30])
>>> series.hash_encode(stop=200)
0 53
1 51
2 124
dtype: int32
You can choose to include name while hash
encoding by specifying `use_name=True`
>>> series.hash_encode(stop=200, use_name=True)
0 131
1 29
2 76
dtype: int32<|endoftext|> |
02b319a9f5c8c1f3190494e79e7f52df76b5b0f0012007f3ca3dbf7373d5b664 | def quantile(self, q=0.5, interpolation='linear', exact=True, quant_index=True):
'\n Return values at the given quantile.\n\n Parameters\n ----------\n\n q : float or array-like, default 0.5 (50% quantile)\n 0 <= q <= 1, the quantile(s) to compute\n interpolation : {’linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}\n This optional parameter specifies the interpolation method to use,\n when the desired quantile lies between two data points i and j:\n columns : list of str\n List of column names to include.\n exact : boolean\n Whether to use approximate or exact quantile algorithm.\n quant_index : boolean\n Whether to use the list of quantiles as index.\n\n Returns\n -------\n float or Series\n If ``q`` is an array, a Series will be returned where the\n index is ``q`` and the values are the quantiles, otherwise\n a float will be returned.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n dtype: int64\n >>> series.quantile(0.5)\n 2.5\n >>> series.quantile([0.25, 0.5, 0.75])\n 0.25 1.75\n 0.50 2.50\n 0.75 3.25\n dtype: float64\n '
result = self._column.quantile(q, interpolation, exact)
if isinstance(q, Number):
return result
if quant_index:
index = np.asarray(q)
if (len(self) == 0):
result = column_empty_like(index, dtype=self.dtype, masked=True, newsize=len(index))
else:
index = None
return Series(result, index=index, name=self.name) | Return values at the given quantile.
Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
0 <= q <= 1, the quantile(s) to compute
interpolation : {’linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
This optional parameter specifies the interpolation method to use,
when the desired quantile lies between two data points i and j:
columns : list of str
List of column names to include.
exact : boolean
Whether to use approximate or exact quantile algorithm.
quant_index : boolean
Whether to use the list of quantiles as index.
Returns
-------
float or Series
If ``q`` is an array, a Series will be returned where the
index is ``q`` and the values are the quantiles, otherwise
a float will be returned.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4])
>>> series
0 1
1 2
2 3
3 4
dtype: int64
>>> series.quantile(0.5)
2.5
>>> series.quantile([0.25, 0.5, 0.75])
0.25 1.75
0.50 2.50
0.75 3.25
dtype: float64 | python/cudf/cudf/core/series.py | quantile | jdye64/cudf | 1 | python | def quantile(self, q=0.5, interpolation='linear', exact=True, quant_index=True):
'\n Return values at the given quantile.\n\n Parameters\n ----------\n\n q : float or array-like, default 0.5 (50% quantile)\n 0 <= q <= 1, the quantile(s) to compute\n interpolation : {’linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}\n This optional parameter specifies the interpolation method to use,\n when the desired quantile lies between two data points i and j:\n columns : list of str\n List of column names to include.\n exact : boolean\n Whether to use approximate or exact quantile algorithm.\n quant_index : boolean\n Whether to use the list of quantiles as index.\n\n Returns\n -------\n float or Series\n If ``q`` is an array, a Series will be returned where the\n index is ``q`` and the values are the quantiles, otherwise\n a float will be returned.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n dtype: int64\n >>> series.quantile(0.5)\n 2.5\n >>> series.quantile([0.25, 0.5, 0.75])\n 0.25 1.75\n 0.50 2.50\n 0.75 3.25\n dtype: float64\n '
result = self._column.quantile(q, interpolation, exact)
if isinstance(q, Number):
return result
if quant_index:
index = np.asarray(q)
if (len(self) == 0):
result = column_empty_like(index, dtype=self.dtype, masked=True, newsize=len(index))
else:
index = None
return Series(result, index=index, name=self.name) | def quantile(self, q=0.5, interpolation='linear', exact=True, quant_index=True):
'\n Return values at the given quantile.\n\n Parameters\n ----------\n\n q : float or array-like, default 0.5 (50% quantile)\n 0 <= q <= 1, the quantile(s) to compute\n interpolation : {’linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}\n This optional parameter specifies the interpolation method to use,\n when the desired quantile lies between two data points i and j:\n columns : list of str\n List of column names to include.\n exact : boolean\n Whether to use approximate or exact quantile algorithm.\n quant_index : boolean\n Whether to use the list of quantiles as index.\n\n Returns\n -------\n float or Series\n If ``q`` is an array, a Series will be returned where the\n index is ``q`` and the values are the quantiles, otherwise\n a float will be returned.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 2, 3, 4])\n >>> series\n 0 1\n 1 2\n 2 3\n 3 4\n dtype: int64\n >>> series.quantile(0.5)\n 2.5\n >>> series.quantile([0.25, 0.5, 0.75])\n 0.25 1.75\n 0.50 2.50\n 0.75 3.25\n dtype: float64\n '
result = self._column.quantile(q, interpolation, exact)
if isinstance(q, Number):
return result
if quant_index:
index = np.asarray(q)
if (len(self) == 0):
result = column_empty_like(index, dtype=self.dtype, masked=True, newsize=len(index))
else:
index = None
return Series(result, index=index, name=self.name)<|docstring|>Return values at the given quantile.
Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
0 <= q <= 1, the quantile(s) to compute
interpolation : {’linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
This optional parameter specifies the interpolation method to use,
when the desired quantile lies between two data points i and j:
columns : list of str
List of column names to include.
exact : boolean
Whether to use approximate or exact quantile algorithm.
quant_index : boolean
Whether to use the list of quantiles as index.
Returns
-------
float or Series
If ``q`` is an array, a Series will be returned where the
index is ``q`` and the values are the quantiles, otherwise
a float will be returned.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4])
>>> series
0 1
1 2
2 3
3 4
dtype: int64
>>> series.quantile(0.5)
2.5
>>> series.quantile([0.25, 0.5, 0.75])
0.25 1.75
0.50 2.50
0.75 3.25
dtype: float64<|endoftext|> |
829e5cac38d643c22ae916c13b9c57c1674f859ee61fd490e0505db6232f8c80 | @docutils.doc_describe()
def describe(self, percentiles=None, include=None, exclude=None, datetime_is_numeric=False):
'{docstring}'
def _prepare_percentiles(percentiles):
percentiles = list(percentiles)
if (not all(((0 <= x <= 1) for x in percentiles))):
raise ValueError('All percentiles must be between 0 and 1, inclusive.')
if (0.5 not in percentiles):
percentiles.append(0.5)
percentiles = np.sort(percentiles)
return percentiles
def _format_percentile_names(percentiles):
return ['{0}%'.format(int((x * 100))) for x in percentiles]
def _format_stats_values(stats_data):
return list(map((lambda x: round(x, 6)), stats_data))
def _describe_numeric(self):
index = ((['count', 'mean', 'std', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([self.count(), self.mean(), self.std(), self.min()] + self.quantile(percentiles).to_array(fillna='pandas').tolist()) + [self.max()])
data = _format_stats_values(data)
return Series(data=data, index=index, nan_as_null=False, name=self.name)
def _describe_timedelta(self):
index = ((['count', 'mean', 'std', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([str(self.count()), str(self.mean()), str(self.std()), str(pd.Timedelta(self.min()))] + self.quantile(percentiles).astype('str').to_array(fillna='pandas').tolist()) + [str(pd.Timedelta(self.max()))])
return Series(data=data, index=index, dtype='str', nan_as_null=False, name=self.name)
def _describe_categorical(self):
index = ['count', 'unique', 'top', 'freq']
val_counts = self.value_counts(ascending=False)
data = [self.count(), self.unique().size]
if (data[1] > 0):
(top, freq) = (val_counts.index[0], val_counts.iloc[0])
data += [str(top), freq]
else:
data += [None, None]
return Series(data=data, dtype='str', index=index, nan_as_null=False, name=self.name)
def _describe_timestamp(self):
index = ((['count', 'mean', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([str(self.count()), str(self.mean().to_numpy().astype('datetime64[ns]')), str(pd.Timestamp(self.min().astype('datetime64[ns]')))] + self.quantile(percentiles).astype('str').to_array(fillna='pandas').tolist()) + [str(pd.Timestamp(self.max().astype('datetime64[ns]')))])
return Series(data=data, dtype='str', index=index, nan_as_null=False, name=self.name)
if (percentiles is not None):
percentiles = _prepare_percentiles(percentiles)
else:
percentiles = np.array([0.25, 0.5, 0.75])
if is_bool_dtype(self.dtype):
return _describe_categorical(self)
elif isinstance(self._column, cudf.core.column.NumericalColumn):
return _describe_numeric(self)
elif isinstance(self._column, cudf.core.column.TimeDeltaColumn):
return _describe_timedelta(self)
elif isinstance(self._column, cudf.core.column.DatetimeColumn):
return _describe_timestamp(self)
else:
return _describe_categorical(self) | {docstring} | python/cudf/cudf/core/series.py | describe | jdye64/cudf | 1 | python | @docutils.doc_describe()
def describe(self, percentiles=None, include=None, exclude=None, datetime_is_numeric=False):
def _prepare_percentiles(percentiles):
percentiles = list(percentiles)
if (not all(((0 <= x <= 1) for x in percentiles))):
raise ValueError('All percentiles must be between 0 and 1, inclusive.')
if (0.5 not in percentiles):
percentiles.append(0.5)
percentiles = np.sort(percentiles)
return percentiles
def _format_percentile_names(percentiles):
return ['{0}%'.format(int((x * 100))) for x in percentiles]
def _format_stats_values(stats_data):
return list(map((lambda x: round(x, 6)), stats_data))
def _describe_numeric(self):
index = ((['count', 'mean', 'std', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([self.count(), self.mean(), self.std(), self.min()] + self.quantile(percentiles).to_array(fillna='pandas').tolist()) + [self.max()])
data = _format_stats_values(data)
return Series(data=data, index=index, nan_as_null=False, name=self.name)
def _describe_timedelta(self):
index = ((['count', 'mean', 'std', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([str(self.count()), str(self.mean()), str(self.std()), str(pd.Timedelta(self.min()))] + self.quantile(percentiles).astype('str').to_array(fillna='pandas').tolist()) + [str(pd.Timedelta(self.max()))])
return Series(data=data, index=index, dtype='str', nan_as_null=False, name=self.name)
def _describe_categorical(self):
index = ['count', 'unique', 'top', 'freq']
val_counts = self.value_counts(ascending=False)
data = [self.count(), self.unique().size]
if (data[1] > 0):
(top, freq) = (val_counts.index[0], val_counts.iloc[0])
data += [str(top), freq]
else:
data += [None, None]
return Series(data=data, dtype='str', index=index, nan_as_null=False, name=self.name)
def _describe_timestamp(self):
index = ((['count', 'mean', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([str(self.count()), str(self.mean().to_numpy().astype('datetime64[ns]')), str(pd.Timestamp(self.min().astype('datetime64[ns]')))] + self.quantile(percentiles).astype('str').to_array(fillna='pandas').tolist()) + [str(pd.Timestamp(self.max().astype('datetime64[ns]')))])
return Series(data=data, dtype='str', index=index, nan_as_null=False, name=self.name)
if (percentiles is not None):
percentiles = _prepare_percentiles(percentiles)
else:
percentiles = np.array([0.25, 0.5, 0.75])
if is_bool_dtype(self.dtype):
return _describe_categorical(self)
elif isinstance(self._column, cudf.core.column.NumericalColumn):
return _describe_numeric(self)
elif isinstance(self._column, cudf.core.column.TimeDeltaColumn):
return _describe_timedelta(self)
elif isinstance(self._column, cudf.core.column.DatetimeColumn):
return _describe_timestamp(self)
else:
return _describe_categorical(self) | @docutils.doc_describe()
def describe(self, percentiles=None, include=None, exclude=None, datetime_is_numeric=False):
def _prepare_percentiles(percentiles):
percentiles = list(percentiles)
if (not all(((0 <= x <= 1) for x in percentiles))):
raise ValueError('All percentiles must be between 0 and 1, inclusive.')
if (0.5 not in percentiles):
percentiles.append(0.5)
percentiles = np.sort(percentiles)
return percentiles
def _format_percentile_names(percentiles):
return ['{0}%'.format(int((x * 100))) for x in percentiles]
def _format_stats_values(stats_data):
return list(map((lambda x: round(x, 6)), stats_data))
def _describe_numeric(self):
index = ((['count', 'mean', 'std', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([self.count(), self.mean(), self.std(), self.min()] + self.quantile(percentiles).to_array(fillna='pandas').tolist()) + [self.max()])
data = _format_stats_values(data)
return Series(data=data, index=index, nan_as_null=False, name=self.name)
def _describe_timedelta(self):
index = ((['count', 'mean', 'std', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([str(self.count()), str(self.mean()), str(self.std()), str(pd.Timedelta(self.min()))] + self.quantile(percentiles).astype('str').to_array(fillna='pandas').tolist()) + [str(pd.Timedelta(self.max()))])
return Series(data=data, index=index, dtype='str', nan_as_null=False, name=self.name)
def _describe_categorical(self):
index = ['count', 'unique', 'top', 'freq']
val_counts = self.value_counts(ascending=False)
data = [self.count(), self.unique().size]
if (data[1] > 0):
(top, freq) = (val_counts.index[0], val_counts.iloc[0])
data += [str(top), freq]
else:
data += [None, None]
return Series(data=data, dtype='str', index=index, nan_as_null=False, name=self.name)
def _describe_timestamp(self):
index = ((['count', 'mean', 'min'] + _format_percentile_names(percentiles)) + ['max'])
data = (([str(self.count()), str(self.mean().to_numpy().astype('datetime64[ns]')), str(pd.Timestamp(self.min().astype('datetime64[ns]')))] + self.quantile(percentiles).astype('str').to_array(fillna='pandas').tolist()) + [str(pd.Timestamp(self.max().astype('datetime64[ns]')))])
return Series(data=data, dtype='str', index=index, nan_as_null=False, name=self.name)
if (percentiles is not None):
percentiles = _prepare_percentiles(percentiles)
else:
percentiles = np.array([0.25, 0.5, 0.75])
if is_bool_dtype(self.dtype):
return _describe_categorical(self)
elif isinstance(self._column, cudf.core.column.NumericalColumn):
return _describe_numeric(self)
elif isinstance(self._column, cudf.core.column.TimeDeltaColumn):
return _describe_timedelta(self)
elif isinstance(self._column, cudf.core.column.DatetimeColumn):
return _describe_timestamp(self)
else:
return _describe_categorical(self)<|docstring|>{docstring}<|endoftext|> |
fd4e31f59baf4d8f2b5b6e142630964142d0ac95a832dc40e684ae55d2041358 | def digitize(self, bins, right=False):
'Return the indices of the bins to which each value in series belongs.\n\n Notes\n -----\n Monotonicity of bins is assumed and not checked.\n\n Parameters\n ----------\n bins : np.array\n 1-D monotonically, increasing array with same type as this series.\n right : bool\n Indicates whether interval contains the right or left bin edge.\n\n Returns\n -------\n A new Series containing the indices.\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([0.2, 6.4, 3.0, 1.6])\n >>> bins = cudf.Series([0.0, 1.0, 2.5, 4.0, 10.0])\n >>> inds = s.digitize(bins)\n >>> inds\n 0 1\n 1 4\n 2 3\n 3 2\n dtype: int32\n '
return Series(cudf.core.column.numerical.digitize(self._column, bins, right)) | Return the indices of the bins to which each value in series belongs.
Notes
-----
Monotonicity of bins is assumed and not checked.
Parameters
----------
bins : np.array
1-D monotonically, increasing array with same type as this series.
right : bool
Indicates whether interval contains the right or left bin edge.
Returns
-------
A new Series containing the indices.
Examples
--------
>>> import cudf
>>> s = cudf.Series([0.2, 6.4, 3.0, 1.6])
>>> bins = cudf.Series([0.0, 1.0, 2.5, 4.0, 10.0])
>>> inds = s.digitize(bins)
>>> inds
0 1
1 4
2 3
3 2
dtype: int32 | python/cudf/cudf/core/series.py | digitize | jdye64/cudf | 1 | python | def digitize(self, bins, right=False):
'Return the indices of the bins to which each value in series belongs.\n\n Notes\n -----\n Monotonicity of bins is assumed and not checked.\n\n Parameters\n ----------\n bins : np.array\n 1-D monotonically, increasing array with same type as this series.\n right : bool\n Indicates whether interval contains the right or left bin edge.\n\n Returns\n -------\n A new Series containing the indices.\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([0.2, 6.4, 3.0, 1.6])\n >>> bins = cudf.Series([0.0, 1.0, 2.5, 4.0, 10.0])\n >>> inds = s.digitize(bins)\n >>> inds\n 0 1\n 1 4\n 2 3\n 3 2\n dtype: int32\n '
return Series(cudf.core.column.numerical.digitize(self._column, bins, right)) | def digitize(self, bins, right=False):
'Return the indices of the bins to which each value in series belongs.\n\n Notes\n -----\n Monotonicity of bins is assumed and not checked.\n\n Parameters\n ----------\n bins : np.array\n 1-D monotonically, increasing array with same type as this series.\n right : bool\n Indicates whether interval contains the right or left bin edge.\n\n Returns\n -------\n A new Series containing the indices.\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([0.2, 6.4, 3.0, 1.6])\n >>> bins = cudf.Series([0.0, 1.0, 2.5, 4.0, 10.0])\n >>> inds = s.digitize(bins)\n >>> inds\n 0 1\n 1 4\n 2 3\n 3 2\n dtype: int32\n '
return Series(cudf.core.column.numerical.digitize(self._column, bins, right))<|docstring|>Return the indices of the bins to which each value in series belongs.
Notes
-----
Monotonicity of bins is assumed and not checked.
Parameters
----------
bins : np.array
1-D monotonically, increasing array with same type as this series.
right : bool
Indicates whether interval contains the right or left bin edge.
Returns
-------
A new Series containing the indices.
Examples
--------
>>> import cudf
>>> s = cudf.Series([0.2, 6.4, 3.0, 1.6])
>>> bins = cudf.Series([0.0, 1.0, 2.5, 4.0, 10.0])
>>> inds = s.digitize(bins)
>>> inds
0 1
1 4
2 3
3 2
dtype: int32<|endoftext|> |
9ac58f22e3bf90f7455d6075cc95e57bf8b03255aaaa868b938220a60b832f95 | def diff(self, periods=1):
'Calculate the difference between values at positions i and i - N in\n an array and store the output in a new array.\n\n Returns\n -------\n Series\n First differences of the Series.\n\n Notes\n -----\n Diff currently only supports float and integer dtype columns with\n no null values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 1, 2, 3, 5, 8])\n >>> series\n 0 1\n 1 1\n 2 2\n 3 3\n 4 5\n 5 8\n dtype: int64\n\n Difference with previous row\n\n >>> series.diff()\n 0 <NA>\n 1 0\n 2 1\n 3 1\n 4 2\n 5 3\n dtype: int64\n\n Difference with 3rd previous row\n\n >>> series.diff(periods=3)\n 0 <NA>\n 1 <NA>\n 2 <NA>\n 3 2\n 4 4\n 5 6\n dtype: int64\n\n Difference with following row\n\n >>> series.diff(periods=-1)\n 0 0\n 1 -1\n 2 -1\n 3 -2\n 4 -3\n 5 <NA>\n dtype: int64\n '
if self.has_nulls:
raise AssertionError('Diff currently requires columns with no null values')
if (not np.issubdtype(self.dtype, np.number)):
raise NotImplementedError('Diff currently only supports numeric dtypes')
input_col = self._column
output_col = column_empty_like(input_col)
output_mask = column_empty_like(input_col, dtype='bool')
if (output_col.size > 0):
cudautils.gpu_diff.forall(output_col.size)(input_col, output_col, output_mask, periods)
output_col = column.build_column(data=output_col.data, dtype=output_col.dtype, mask=bools_to_mask(output_mask))
return Series(output_col, name=self.name, index=self.index) | Calculate the difference between values at positions i and i - N in
an array and store the output in a new array.
Returns
-------
Series
First differences of the Series.
Notes
-----
Diff currently only supports float and integer dtype columns with
no null values.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 1, 2, 3, 5, 8])
>>> series
0 1
1 1
2 2
3 3
4 5
5 8
dtype: int64
Difference with previous row
>>> series.diff()
0 <NA>
1 0
2 1
3 1
4 2
5 3
dtype: int64
Difference with 3rd previous row
>>> series.diff(periods=3)
0 <NA>
1 <NA>
2 <NA>
3 2
4 4
5 6
dtype: int64
Difference with following row
>>> series.diff(periods=-1)
0 0
1 -1
2 -1
3 -2
4 -3
5 <NA>
dtype: int64 | python/cudf/cudf/core/series.py | diff | jdye64/cudf | 1 | python | def diff(self, periods=1):
'Calculate the difference between values at positions i and i - N in\n an array and store the output in a new array.\n\n Returns\n -------\n Series\n First differences of the Series.\n\n Notes\n -----\n Diff currently only supports float and integer dtype columns with\n no null values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 1, 2, 3, 5, 8])\n >>> series\n 0 1\n 1 1\n 2 2\n 3 3\n 4 5\n 5 8\n dtype: int64\n\n Difference with previous row\n\n >>> series.diff()\n 0 <NA>\n 1 0\n 2 1\n 3 1\n 4 2\n 5 3\n dtype: int64\n\n Difference with 3rd previous row\n\n >>> series.diff(periods=3)\n 0 <NA>\n 1 <NA>\n 2 <NA>\n 3 2\n 4 4\n 5 6\n dtype: int64\n\n Difference with following row\n\n >>> series.diff(periods=-1)\n 0 0\n 1 -1\n 2 -1\n 3 -2\n 4 -3\n 5 <NA>\n dtype: int64\n '
if self.has_nulls:
raise AssertionError('Diff currently requires columns with no null values')
if (not np.issubdtype(self.dtype, np.number)):
raise NotImplementedError('Diff currently only supports numeric dtypes')
input_col = self._column
output_col = column_empty_like(input_col)
output_mask = column_empty_like(input_col, dtype='bool')
if (output_col.size > 0):
cudautils.gpu_diff.forall(output_col.size)(input_col, output_col, output_mask, periods)
output_col = column.build_column(data=output_col.data, dtype=output_col.dtype, mask=bools_to_mask(output_mask))
return Series(output_col, name=self.name, index=self.index) | def diff(self, periods=1):
'Calculate the difference between values at positions i and i - N in\n an array and store the output in a new array.\n\n Returns\n -------\n Series\n First differences of the Series.\n\n Notes\n -----\n Diff currently only supports float and integer dtype columns with\n no null values.\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([1, 1, 2, 3, 5, 8])\n >>> series\n 0 1\n 1 1\n 2 2\n 3 3\n 4 5\n 5 8\n dtype: int64\n\n Difference with previous row\n\n >>> series.diff()\n 0 <NA>\n 1 0\n 2 1\n 3 1\n 4 2\n 5 3\n dtype: int64\n\n Difference with 3rd previous row\n\n >>> series.diff(periods=3)\n 0 <NA>\n 1 <NA>\n 2 <NA>\n 3 2\n 4 4\n 5 6\n dtype: int64\n\n Difference with following row\n\n >>> series.diff(periods=-1)\n 0 0\n 1 -1\n 2 -1\n 3 -2\n 4 -3\n 5 <NA>\n dtype: int64\n '
if self.has_nulls:
raise AssertionError('Diff currently requires columns with no null values')
if (not np.issubdtype(self.dtype, np.number)):
raise NotImplementedError('Diff currently only supports numeric dtypes')
input_col = self._column
output_col = column_empty_like(input_col)
output_mask = column_empty_like(input_col, dtype='bool')
if (output_col.size > 0):
cudautils.gpu_diff.forall(output_col.size)(input_col, output_col, output_mask, periods)
output_col = column.build_column(data=output_col.data, dtype=output_col.dtype, mask=bools_to_mask(output_mask))
return Series(output_col, name=self.name, index=self.index)<|docstring|>Calculate the difference between values at positions i and i - N in
an array and store the output in a new array.
Returns
-------
Series
First differences of the Series.
Notes
-----
Diff currently only supports float and integer dtype columns with
no null values.
Examples
--------
>>> import cudf
>>> series = cudf.Series([1, 1, 2, 3, 5, 8])
>>> series
0 1
1 1
2 2
3 3
4 5
5 8
dtype: int64
Difference with previous row
>>> series.diff()
0 <NA>
1 0
2 1
3 1
4 2
5 3
dtype: int64
Difference with 3rd previous row
>>> series.diff(periods=3)
0 <NA>
1 <NA>
2 <NA>
3 2
4 4
5 6
dtype: int64
Difference with following row
>>> series.diff(periods=-1)
0 0
1 -1
2 -1
3 -2
4 -3
5 <NA>
dtype: int64<|endoftext|> |
cb5110667a74b4d4f50a5f30917660c057b99983febab07aa3215eca6402e61d | def rename(self, index=None, copy=True):
"\n Alter Series name\n\n Change Series.name with a scalar value\n\n Parameters\n ----------\n index : Scalar, optional\n Scalar to alter the Series.name attribute\n copy : boolean, default True\n Also copy underlying data\n\n Returns\n -------\n Series\n\n Notes\n -----\n Difference from pandas:\n - Supports scalar values only for changing name attribute\n - Not supporting : inplace, level\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 20, 30])\n >>> series\n 0 10\n 1 20\n 2 30\n dtype: int64\n >>> series.name\n >>> renamed_series = series.rename('numeric_series')\n >>> renamed_series\n 0 10\n 1 20\n 2 30\n Name: numeric_series, dtype: int64\n >>> renamed_series.name\n 'numeric_series'\n "
out = self.copy(deep=False)
out = out.set_index(self.index)
if index:
out.name = index
return out.copy(deep=copy) | Alter Series name
Change Series.name with a scalar value
Parameters
----------
index : Scalar, optional
Scalar to alter the Series.name attribute
copy : boolean, default True
Also copy underlying data
Returns
-------
Series
Notes
-----
Difference from pandas:
- Supports scalar values only for changing name attribute
- Not supporting : inplace, level
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 20, 30])
>>> series
0 10
1 20
2 30
dtype: int64
>>> series.name
>>> renamed_series = series.rename('numeric_series')
>>> renamed_series
0 10
1 20
2 30
Name: numeric_series, dtype: int64
>>> renamed_series.name
'numeric_series' | python/cudf/cudf/core/series.py | rename | jdye64/cudf | 1 | python | def rename(self, index=None, copy=True):
"\n Alter Series name\n\n Change Series.name with a scalar value\n\n Parameters\n ----------\n index : Scalar, optional\n Scalar to alter the Series.name attribute\n copy : boolean, default True\n Also copy underlying data\n\n Returns\n -------\n Series\n\n Notes\n -----\n Difference from pandas:\n - Supports scalar values only for changing name attribute\n - Not supporting : inplace, level\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 20, 30])\n >>> series\n 0 10\n 1 20\n 2 30\n dtype: int64\n >>> series.name\n >>> renamed_series = series.rename('numeric_series')\n >>> renamed_series\n 0 10\n 1 20\n 2 30\n Name: numeric_series, dtype: int64\n >>> renamed_series.name\n 'numeric_series'\n "
out = self.copy(deep=False)
out = out.set_index(self.index)
if index:
out.name = index
return out.copy(deep=copy) | def rename(self, index=None, copy=True):
"\n Alter Series name\n\n Change Series.name with a scalar value\n\n Parameters\n ----------\n index : Scalar, optional\n Scalar to alter the Series.name attribute\n copy : boolean, default True\n Also copy underlying data\n\n Returns\n -------\n Series\n\n Notes\n -----\n Difference from pandas:\n - Supports scalar values only for changing name attribute\n - Not supporting : inplace, level\n\n Examples\n --------\n >>> import cudf\n >>> series = cudf.Series([10, 20, 30])\n >>> series\n 0 10\n 1 20\n 2 30\n dtype: int64\n >>> series.name\n >>> renamed_series = series.rename('numeric_series')\n >>> renamed_series\n 0 10\n 1 20\n 2 30\n Name: numeric_series, dtype: int64\n >>> renamed_series.name\n 'numeric_series'\n "
out = self.copy(deep=False)
out = out.set_index(self.index)
if index:
out.name = index
return out.copy(deep=copy)<|docstring|>Alter Series name
Change Series.name with a scalar value
Parameters
----------
index : Scalar, optional
Scalar to alter the Series.name attribute
copy : boolean, default True
Also copy underlying data
Returns
-------
Series
Notes
-----
Difference from pandas:
- Supports scalar values only for changing name attribute
- Not supporting : inplace, level
Examples
--------
>>> import cudf
>>> series = cudf.Series([10, 20, 30])
>>> series
0 10
1 20
2 30
dtype: int64
>>> series.name
>>> renamed_series = series.rename('numeric_series')
>>> renamed_series
0 10
1 20
2 30
Name: numeric_series, dtype: int64
>>> renamed_series.name
'numeric_series'<|endoftext|> |
072d9bd017f40c1a9fcbfa133996b01ea4eb0203a428d9f319ea8270b57406d4 | def _align_to_index(self, index, how='outer', sort=True, allow_non_unique=False):
'\n Align to the given Index. See _align_indices below.\n '
index = as_index(index)
if self.index.equals(index):
return self
if (not allow_non_unique):
if ((len(self) != len(self.index.unique())) or (len(index) != len(index.unique()))):
raise ValueError('Cannot align indices with non-unique values')
lhs = self.to_frame(0)
rhs = cudf.DataFrame(index=as_index(index))
if (how == 'left'):
tmp_col_id = str(uuid4())
lhs[tmp_col_id] = column.arange(len(lhs))
elif (how == 'right'):
tmp_col_id = str(uuid4())
rhs[tmp_col_id] = column.arange(len(rhs))
result = lhs.join(rhs, how=how, sort=sort)
if ((how == 'left') or (how == 'right')):
result = result.sort_values(tmp_col_id)[0]
else:
result = result[0]
result.name = self.name
result.index.names = index.names
return result | Align to the given Index. See _align_indices below. | python/cudf/cudf/core/series.py | _align_to_index | jdye64/cudf | 1 | python | def _align_to_index(self, index, how='outer', sort=True, allow_non_unique=False):
'\n \n '
index = as_index(index)
if self.index.equals(index):
return self
if (not allow_non_unique):
if ((len(self) != len(self.index.unique())) or (len(index) != len(index.unique()))):
raise ValueError('Cannot align indices with non-unique values')
lhs = self.to_frame(0)
rhs = cudf.DataFrame(index=as_index(index))
if (how == 'left'):
tmp_col_id = str(uuid4())
lhs[tmp_col_id] = column.arange(len(lhs))
elif (how == 'right'):
tmp_col_id = str(uuid4())
rhs[tmp_col_id] = column.arange(len(rhs))
result = lhs.join(rhs, how=how, sort=sort)
if ((how == 'left') or (how == 'right')):
result = result.sort_values(tmp_col_id)[0]
else:
result = result[0]
result.name = self.name
result.index.names = index.names
return result | def _align_to_index(self, index, how='outer', sort=True, allow_non_unique=False):
'\n \n '
index = as_index(index)
if self.index.equals(index):
return self
if (not allow_non_unique):
if ((len(self) != len(self.index.unique())) or (len(index) != len(index.unique()))):
raise ValueError('Cannot align indices with non-unique values')
lhs = self.to_frame(0)
rhs = cudf.DataFrame(index=as_index(index))
if (how == 'left'):
tmp_col_id = str(uuid4())
lhs[tmp_col_id] = column.arange(len(lhs))
elif (how == 'right'):
tmp_col_id = str(uuid4())
rhs[tmp_col_id] = column.arange(len(rhs))
result = lhs.join(rhs, how=how, sort=sort)
if ((how == 'left') or (how == 'right')):
result = result.sort_values(tmp_col_id)[0]
else:
result = result[0]
result.name = self.name
result.index.names = index.names
return result<|docstring|>Align to the given Index. See _align_indices below.<|endoftext|> |
49734f8ef82dda8b1b36a504508bed93222ee3259f7ed9ce6880955dd25532a6 | def keys(self):
"\n Return alias for index.\n\n Returns\n -------\n Index\n Index of the Series.\n\n Examples\n --------\n >>> import cudf\n >>> sr = cudf.Series([10, 11, 12, 13, 14, 15])\n >>> sr\n 0 10\n 1 11\n 2 12\n 3 13\n 4 14\n 5 15\n dtype: int64\n\n >>> sr.keys()\n RangeIndex(start=0, stop=6)\n >>> sr = cudf.Series(['a', 'b', 'c'])\n >>> sr\n 0 a\n 1 b\n 2 c\n dtype: object\n >>> sr.keys()\n RangeIndex(start=0, stop=3)\n >>> sr = cudf.Series([1, 2, 3], index=['a', 'b', 'c'])\n >>> sr\n a 1\n b 2\n c 3\n dtype: int64\n >>> sr.keys()\n StringIndex(['a' 'b' 'c'], dtype='object')\n "
return self.index | Return alias for index.
Returns
-------
Index
Index of the Series.
Examples
--------
>>> import cudf
>>> sr = cudf.Series([10, 11, 12, 13, 14, 15])
>>> sr
0 10
1 11
2 12
3 13
4 14
5 15
dtype: int64
>>> sr.keys()
RangeIndex(start=0, stop=6)
>>> sr = cudf.Series(['a', 'b', 'c'])
>>> sr
0 a
1 b
2 c
dtype: object
>>> sr.keys()
RangeIndex(start=0, stop=3)
>>> sr = cudf.Series([1, 2, 3], index=['a', 'b', 'c'])
>>> sr
a 1
b 2
c 3
dtype: int64
>>> sr.keys()
StringIndex(['a' 'b' 'c'], dtype='object') | python/cudf/cudf/core/series.py | keys | jdye64/cudf | 1 | python | def keys(self):
"\n Return alias for index.\n\n Returns\n -------\n Index\n Index of the Series.\n\n Examples\n --------\n >>> import cudf\n >>> sr = cudf.Series([10, 11, 12, 13, 14, 15])\n >>> sr\n 0 10\n 1 11\n 2 12\n 3 13\n 4 14\n 5 15\n dtype: int64\n\n >>> sr.keys()\n RangeIndex(start=0, stop=6)\n >>> sr = cudf.Series(['a', 'b', 'c'])\n >>> sr\n 0 a\n 1 b\n 2 c\n dtype: object\n >>> sr.keys()\n RangeIndex(start=0, stop=3)\n >>> sr = cudf.Series([1, 2, 3], index=['a', 'b', 'c'])\n >>> sr\n a 1\n b 2\n c 3\n dtype: int64\n >>> sr.keys()\n StringIndex(['a' 'b' 'c'], dtype='object')\n "
return self.index | def keys(self):
"\n Return alias for index.\n\n Returns\n -------\n Index\n Index of the Series.\n\n Examples\n --------\n >>> import cudf\n >>> sr = cudf.Series([10, 11, 12, 13, 14, 15])\n >>> sr\n 0 10\n 1 11\n 2 12\n 3 13\n 4 14\n 5 15\n dtype: int64\n\n >>> sr.keys()\n RangeIndex(start=0, stop=6)\n >>> sr = cudf.Series(['a', 'b', 'c'])\n >>> sr\n 0 a\n 1 b\n 2 c\n dtype: object\n >>> sr.keys()\n RangeIndex(start=0, stop=3)\n >>> sr = cudf.Series([1, 2, 3], index=['a', 'b', 'c'])\n >>> sr\n a 1\n b 2\n c 3\n dtype: int64\n >>> sr.keys()\n StringIndex(['a' 'b' 'c'], dtype='object')\n "
return self.index<|docstring|>Return alias for index.
Returns
-------
Index
Index of the Series.
Examples
--------
>>> import cudf
>>> sr = cudf.Series([10, 11, 12, 13, 14, 15])
>>> sr
0 10
1 11
2 12
3 13
4 14
5 15
dtype: int64
>>> sr.keys()
RangeIndex(start=0, stop=6)
>>> sr = cudf.Series(['a', 'b', 'c'])
>>> sr
0 a
1 b
2 c
dtype: object
>>> sr.keys()
RangeIndex(start=0, stop=3)
>>> sr = cudf.Series([1, 2, 3], index=['a', 'b', 'c'])
>>> sr
a 1
b 2
c 3
dtype: int64
>>> sr.keys()
StringIndex(['a' 'b' 'c'], dtype='object')<|endoftext|> |
20eb1b107651e10316907df9f3a838ad241417a116cb79e84cb448f74ae6eb68 | def explode(self, ignore_index=False):
'\n Transform each element of a list-like to a row, replicating index\n values.\n\n Parameters\n ----------\n ignore_index : bool, default False\n If True, the resulting index will be labeled 0, 1, …, n - 1.\n\n Returns\n -------\n DataFrame\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([[1, 2, 3], [], None, [4, 5]])\n >>> s\n 0 [1, 2, 3]\n 1 []\n 2 None\n 3 [4, 5]\n dtype: list\n >>> s.explode()\n 0 1\n 0 2\n 0 3\n 1 <NA>\n 2 <NA>\n 3 4\n 3 5\n dtype: int64\n '
if (not is_list_dtype(self._column.dtype)):
data = self._data.copy(deep=True)
idx = (None if ignore_index else self._index.copy(deep=True))
return self.__class__._from_data(data, index=idx)
return super()._explode(self._column_names[0], ignore_index) | Transform each element of a list-like to a row, replicating index
values.
Parameters
----------
ignore_index : bool, default False
If True, the resulting index will be labeled 0, 1, …, n - 1.
Returns
-------
DataFrame
Examples
--------
>>> import cudf
>>> s = cudf.Series([[1, 2, 3], [], None, [4, 5]])
>>> s
0 [1, 2, 3]
1 []
2 None
3 [4, 5]
dtype: list
>>> s.explode()
0 1
0 2
0 3
1 <NA>
2 <NA>
3 4
3 5
dtype: int64 | python/cudf/cudf/core/series.py | explode | jdye64/cudf | 1 | python | def explode(self, ignore_index=False):
'\n Transform each element of a list-like to a row, replicating index\n values.\n\n Parameters\n ----------\n ignore_index : bool, default False\n If True, the resulting index will be labeled 0, 1, …, n - 1.\n\n Returns\n -------\n DataFrame\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([[1, 2, 3], [], None, [4, 5]])\n >>> s\n 0 [1, 2, 3]\n 1 []\n 2 None\n 3 [4, 5]\n dtype: list\n >>> s.explode()\n 0 1\n 0 2\n 0 3\n 1 <NA>\n 2 <NA>\n 3 4\n 3 5\n dtype: int64\n '
if (not is_list_dtype(self._column.dtype)):
data = self._data.copy(deep=True)
idx = (None if ignore_index else self._index.copy(deep=True))
return self.__class__._from_data(data, index=idx)
return super()._explode(self._column_names[0], ignore_index) | def explode(self, ignore_index=False):
'\n Transform each element of a list-like to a row, replicating index\n values.\n\n Parameters\n ----------\n ignore_index : bool, default False\n If True, the resulting index will be labeled 0, 1, …, n - 1.\n\n Returns\n -------\n DataFrame\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([[1, 2, 3], [], None, [4, 5]])\n >>> s\n 0 [1, 2, 3]\n 1 []\n 2 None\n 3 [4, 5]\n dtype: list\n >>> s.explode()\n 0 1\n 0 2\n 0 3\n 1 <NA>\n 2 <NA>\n 3 4\n 3 5\n dtype: int64\n '
if (not is_list_dtype(self._column.dtype)):
data = self._data.copy(deep=True)
idx = (None if ignore_index else self._index.copy(deep=True))
return self.__class__._from_data(data, index=idx)
return super()._explode(self._column_names[0], ignore_index)<|docstring|>Transform each element of a list-like to a row, replicating index
values.
Parameters
----------
ignore_index : bool, default False
If True, the resulting index will be labeled 0, 1, …, n - 1.
Returns
-------
DataFrame
Examples
--------
>>> import cudf
>>> s = cudf.Series([[1, 2, 3], [], None, [4, 5]])
>>> s
0 [1, 2, 3]
1 []
2 None
3 [4, 5]
dtype: list
>>> s.explode()
0 1
0 2
0 3
1 <NA>
2 <NA>
3 4
3 5
dtype: int64<|endoftext|> |
b8682827a7c6e42b5da3a36f7d8ee42ad71eb97c196b4b64596c49e55cd027bc | def pct_change(self, periods=1, fill_method='ffill', limit=None, freq=None):
"\n Calculates the percent change between sequential elements\n in the Series.\n\n Parameters\n ----------\n periods : int, default 1\n Periods to shift for forming percent change.\n fill_method : str, default 'ffill'\n How to handle NAs before computing percent changes.\n limit : int, optional\n The number of consecutive NAs to fill before stopping.\n Not yet implemented.\n freq : str, optional\n Increment to use from time series API.\n Not yet implemented.\n\n Returns\n -------\n Series\n "
if (limit is not None):
raise NotImplementedError('limit parameter not supported yet.')
if (freq is not None):
raise NotImplementedError('freq parameter not supported yet.')
elif (fill_method not in {'ffill', 'pad', 'bfill', 'backfill'}):
raise ValueError("fill_method must be one of 'ffill', 'pad', 'bfill', or 'backfill'.")
data = self.fillna(method=fill_method, limit=limit)
diff = data.diff(periods=periods)
change = (diff / data.shift(periods=periods, freq=freq))
return change | Calculates the percent change between sequential elements
in the Series.
Parameters
----------
periods : int, default 1
Periods to shift for forming percent change.
fill_method : str, default 'ffill'
How to handle NAs before computing percent changes.
limit : int, optional
The number of consecutive NAs to fill before stopping.
Not yet implemented.
freq : str, optional
Increment to use from time series API.
Not yet implemented.
Returns
-------
Series | python/cudf/cudf/core/series.py | pct_change | jdye64/cudf | 1 | python | def pct_change(self, periods=1, fill_method='ffill', limit=None, freq=None):
"\n Calculates the percent change between sequential elements\n in the Series.\n\n Parameters\n ----------\n periods : int, default 1\n Periods to shift for forming percent change.\n fill_method : str, default 'ffill'\n How to handle NAs before computing percent changes.\n limit : int, optional\n The number of consecutive NAs to fill before stopping.\n Not yet implemented.\n freq : str, optional\n Increment to use from time series API.\n Not yet implemented.\n\n Returns\n -------\n Series\n "
if (limit is not None):
raise NotImplementedError('limit parameter not supported yet.')
if (freq is not None):
raise NotImplementedError('freq parameter not supported yet.')
elif (fill_method not in {'ffill', 'pad', 'bfill', 'backfill'}):
raise ValueError("fill_method must be one of 'ffill', 'pad', 'bfill', or 'backfill'.")
data = self.fillna(method=fill_method, limit=limit)
diff = data.diff(periods=periods)
change = (diff / data.shift(periods=periods, freq=freq))
return change | def pct_change(self, periods=1, fill_method='ffill', limit=None, freq=None):
"\n Calculates the percent change between sequential elements\n in the Series.\n\n Parameters\n ----------\n periods : int, default 1\n Periods to shift for forming percent change.\n fill_method : str, default 'ffill'\n How to handle NAs before computing percent changes.\n limit : int, optional\n The number of consecutive NAs to fill before stopping.\n Not yet implemented.\n freq : str, optional\n Increment to use from time series API.\n Not yet implemented.\n\n Returns\n -------\n Series\n "
if (limit is not None):
raise NotImplementedError('limit parameter not supported yet.')
if (freq is not None):
raise NotImplementedError('freq parameter not supported yet.')
elif (fill_method not in {'ffill', 'pad', 'bfill', 'backfill'}):
raise ValueError("fill_method must be one of 'ffill', 'pad', 'bfill', or 'backfill'.")
data = self.fillna(method=fill_method, limit=limit)
diff = data.diff(periods=periods)
change = (diff / data.shift(periods=periods, freq=freq))
return change<|docstring|>Calculates the percent change between sequential elements
in the Series.
Parameters
----------
periods : int, default 1
Periods to shift for forming percent change.
fill_method : str, default 'ffill'
How to handle NAs before computing percent changes.
limit : int, optional
The number of consecutive NAs to fill before stopping.
Not yet implemented.
freq : str, optional
Increment to use from time series API.
Not yet implemented.
Returns
-------
Series<|endoftext|> |
b285751c8e24f92664862e25850eac93094abb16564334dedf2dcd118241135a | @property
def year(self):
'\n The year of the datetime.\n\n Examples\n --------\n >>> import cudf\n >>> import pandas as pd\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="Y"))\n >>> datetime_series\n 0 2000-12-31\n 1 2001-12-31\n 2 2002-12-31\n dtype: datetime64[ns]\n >>> datetime_series.dt.year\n 0 2000\n 1 2001\n 2 2002\n dtype: int16\n '
return self._get_dt_field('year') | The year of the datetime.
Examples
--------
>>> import cudf
>>> import pandas as pd
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="Y"))
>>> datetime_series
0 2000-12-31
1 2001-12-31
2 2002-12-31
dtype: datetime64[ns]
>>> datetime_series.dt.year
0 2000
1 2001
2 2002
dtype: int16 | python/cudf/cudf/core/series.py | year | jdye64/cudf | 1 | python | @property
def year(self):
'\n The year of the datetime.\n\n Examples\n --------\n >>> import cudf\n >>> import pandas as pd\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="Y"))\n >>> datetime_series\n 0 2000-12-31\n 1 2001-12-31\n 2 2002-12-31\n dtype: datetime64[ns]\n >>> datetime_series.dt.year\n 0 2000\n 1 2001\n 2 2002\n dtype: int16\n '
return self._get_dt_field('year') | @property
def year(self):
'\n The year of the datetime.\n\n Examples\n --------\n >>> import cudf\n >>> import pandas as pd\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="Y"))\n >>> datetime_series\n 0 2000-12-31\n 1 2001-12-31\n 2 2002-12-31\n dtype: datetime64[ns]\n >>> datetime_series.dt.year\n 0 2000\n 1 2001\n 2 2002\n dtype: int16\n '
return self._get_dt_field('year')<|docstring|>The year of the datetime.
Examples
--------
>>> import cudf
>>> import pandas as pd
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="Y"))
>>> datetime_series
0 2000-12-31
1 2001-12-31
2 2002-12-31
dtype: datetime64[ns]
>>> datetime_series.dt.year
0 2000
1 2001
2 2002
dtype: int16<|endoftext|> |
14186a77dab01167f75059e889153c45f92033e43e95fa3b895092da1d94f8d7 | @property
def month(self):
'\n The month as January=1, December=12.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="M"))\n >>> datetime_series\n 0 2000-01-31\n 1 2000-02-29\n 2 2000-03-31\n dtype: datetime64[ns]\n >>> datetime_series.dt.month\n 0 1\n 1 2\n 2 3\n dtype: int16\n '
return self._get_dt_field('month') | The month as January=1, December=12.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="M"))
>>> datetime_series
0 2000-01-31
1 2000-02-29
2 2000-03-31
dtype: datetime64[ns]
>>> datetime_series.dt.month
0 1
1 2
2 3
dtype: int16 | python/cudf/cudf/core/series.py | month | jdye64/cudf | 1 | python | @property
def month(self):
'\n The month as January=1, December=12.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="M"))\n >>> datetime_series\n 0 2000-01-31\n 1 2000-02-29\n 2 2000-03-31\n dtype: datetime64[ns]\n >>> datetime_series.dt.month\n 0 1\n 1 2\n 2 3\n dtype: int16\n '
return self._get_dt_field('month') | @property
def month(self):
'\n The month as January=1, December=12.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="M"))\n >>> datetime_series\n 0 2000-01-31\n 1 2000-02-29\n 2 2000-03-31\n dtype: datetime64[ns]\n >>> datetime_series.dt.month\n 0 1\n 1 2\n 2 3\n dtype: int16\n '
return self._get_dt_field('month')<|docstring|>The month as January=1, December=12.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="M"))
>>> datetime_series
0 2000-01-31
1 2000-02-29
2 2000-03-31
dtype: datetime64[ns]
>>> datetime_series.dt.month
0 1
1 2
2 3
dtype: int16<|endoftext|> |
796e89a62ecd848542d716f4ccba2a54dbe9e8166d772e8ee4dd35eb8c204413 | @property
def day(self):
'\n The day of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="D"))\n >>> datetime_series\n 0 2000-01-01\n 1 2000-01-02\n 2 2000-01-03\n dtype: datetime64[ns]\n >>> datetime_series.dt.day\n 0 1\n 1 2\n 2 3\n dtype: int16\n '
return self._get_dt_field('day') | The day of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="D"))
>>> datetime_series
0 2000-01-01
1 2000-01-02
2 2000-01-03
dtype: datetime64[ns]
>>> datetime_series.dt.day
0 1
1 2
2 3
dtype: int16 | python/cudf/cudf/core/series.py | day | jdye64/cudf | 1 | python | @property
def day(self):
'\n The day of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="D"))\n >>> datetime_series\n 0 2000-01-01\n 1 2000-01-02\n 2 2000-01-03\n dtype: datetime64[ns]\n >>> datetime_series.dt.day\n 0 1\n 1 2\n 2 3\n dtype: int16\n '
return self._get_dt_field('day') | @property
def day(self):
'\n The day of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="D"))\n >>> datetime_series\n 0 2000-01-01\n 1 2000-01-02\n 2 2000-01-03\n dtype: datetime64[ns]\n >>> datetime_series.dt.day\n 0 1\n 1 2\n 2 3\n dtype: int16\n '
return self._get_dt_field('day')<|docstring|>The day of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="D"))
>>> datetime_series
0 2000-01-01
1 2000-01-02
2 2000-01-03
dtype: datetime64[ns]
>>> datetime_series.dt.day
0 1
1 2
2 3
dtype: int16<|endoftext|> |
3207437f6a36e564d16b67e88d9a86f4114419e1c6f16d61dfb126a6ae4fc5c5 | @property
def hour(self):
'\n The hours of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="h"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 01:00:00\n 2 2000-01-01 02:00:00\n dtype: datetime64[ns]\n >>> datetime_series.dt.hour\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('hour') | The hours of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="h"))
>>> datetime_series
0 2000-01-01 00:00:00
1 2000-01-01 01:00:00
2 2000-01-01 02:00:00
dtype: datetime64[ns]
>>> datetime_series.dt.hour
0 0
1 1
2 2
dtype: int16 | python/cudf/cudf/core/series.py | hour | jdye64/cudf | 1 | python | @property
def hour(self):
'\n The hours of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="h"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 01:00:00\n 2 2000-01-01 02:00:00\n dtype: datetime64[ns]\n >>> datetime_series.dt.hour\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('hour') | @property
def hour(self):
'\n The hours of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="h"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 01:00:00\n 2 2000-01-01 02:00:00\n dtype: datetime64[ns]\n >>> datetime_series.dt.hour\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('hour')<|docstring|>The hours of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="h"))
>>> datetime_series
0 2000-01-01 00:00:00
1 2000-01-01 01:00:00
2 2000-01-01 02:00:00
dtype: datetime64[ns]
>>> datetime_series.dt.hour
0 0
1 1
2 2
dtype: int16<|endoftext|> |
881a1d8fd3b3567df7cb7f22af07523d644cc1472d561506531b412b9a1861d7 | @property
def minute(self):
'\n The minutes of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="T"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 00:01:00\n 2 2000-01-01 00:02:00\n dtype: datetime64[ns]\n >>> datetime_series.dt.minute\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('minute') | The minutes of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="T"))
>>> datetime_series
0 2000-01-01 00:00:00
1 2000-01-01 00:01:00
2 2000-01-01 00:02:00
dtype: datetime64[ns]
>>> datetime_series.dt.minute
0 0
1 1
2 2
dtype: int16 | python/cudf/cudf/core/series.py | minute | jdye64/cudf | 1 | python | @property
def minute(self):
'\n The minutes of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="T"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 00:01:00\n 2 2000-01-01 00:02:00\n dtype: datetime64[ns]\n >>> datetime_series.dt.minute\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('minute') | @property
def minute(self):
'\n The minutes of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="T"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 00:01:00\n 2 2000-01-01 00:02:00\n dtype: datetime64[ns]\n >>> datetime_series.dt.minute\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('minute')<|docstring|>The minutes of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="T"))
>>> datetime_series
0 2000-01-01 00:00:00
1 2000-01-01 00:01:00
2 2000-01-01 00:02:00
dtype: datetime64[ns]
>>> datetime_series.dt.minute
0 0
1 1
2 2
dtype: int16<|endoftext|> |
046ae41eb01528c29b81ee24b2398684b6099a28787e8c97a6b77a6cda6720c1 | @property
def second(self):
'\n The seconds of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="s"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 00:00:01\n 2 2000-01-01 00:00:02\n dtype: datetime64[ns]\n >>> datetime_series.dt.second\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('second') | The seconds of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="s"))
>>> datetime_series
0 2000-01-01 00:00:00
1 2000-01-01 00:00:01
2 2000-01-01 00:00:02
dtype: datetime64[ns]
>>> datetime_series.dt.second
0 0
1 1
2 2
dtype: int16 | python/cudf/cudf/core/series.py | second | jdye64/cudf | 1 | python | @property
def second(self):
'\n The seconds of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="s"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 00:00:01\n 2 2000-01-01 00:00:02\n dtype: datetime64[ns]\n >>> datetime_series.dt.second\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('second') | @property
def second(self):
'\n The seconds of the datetime.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range("2000-01-01",\n ... periods=3, freq="s"))\n >>> datetime_series\n 0 2000-01-01 00:00:00\n 1 2000-01-01 00:00:01\n 2 2000-01-01 00:00:02\n dtype: datetime64[ns]\n >>> datetime_series.dt.second\n 0 0\n 1 1\n 2 2\n dtype: int16\n '
return self._get_dt_field('second')<|docstring|>The seconds of the datetime.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range("2000-01-01",
... periods=3, freq="s"))
>>> datetime_series
0 2000-01-01 00:00:00
1 2000-01-01 00:00:01
2 2000-01-01 00:00:02
dtype: datetime64[ns]
>>> datetime_series.dt.second
0 0
1 1
2 2
dtype: int16<|endoftext|> |
b4beec41217bc06bf3be4e9fc84c22240a0d706da7b712665a886dbf85c6015f | @property
def weekday(self):
"\n The day of the week with Monday=0, Sunday=6.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.weekday\n 0 5\n 1 6\n 2 0\n 3 1\n 4 2\n 5 3\n 6 4\n 7 5\n 8 6\n dtype: int16\n "
return self._get_dt_field('weekday') | The day of the week with Monday=0, Sunday=6.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.weekday
0 5
1 6
2 0
3 1
4 2
5 3
6 4
7 5
8 6
dtype: int16 | python/cudf/cudf/core/series.py | weekday | jdye64/cudf | 1 | python | @property
def weekday(self):
"\n The day of the week with Monday=0, Sunday=6.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.weekday\n 0 5\n 1 6\n 2 0\n 3 1\n 4 2\n 5 3\n 6 4\n 7 5\n 8 6\n dtype: int16\n "
return self._get_dt_field('weekday') | @property
def weekday(self):
"\n The day of the week with Monday=0, Sunday=6.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.weekday\n 0 5\n 1 6\n 2 0\n 3 1\n 4 2\n 5 3\n 6 4\n 7 5\n 8 6\n dtype: int16\n "
return self._get_dt_field('weekday')<|docstring|>The day of the week with Monday=0, Sunday=6.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.weekday
0 5
1 6
2 0
3 1
4 2
5 3
6 4
7 5
8 6
dtype: int16<|endoftext|> |
a451309e4da6d082bfdf856fd11e9fd3cc8ee28a99e3b0e0c2cbbef8cad3d7ef | @property
def dayofweek(self):
"\n The day of the week with Monday=0, Sunday=6.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.dayofweek\n 0 5\n 1 6\n 2 0\n 3 1\n 4 2\n 5 3\n 6 4\n 7 5\n 8 6\n dtype: int16\n "
return self._get_dt_field('weekday') | The day of the week with Monday=0, Sunday=6.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.dayofweek
0 5
1 6
2 0
3 1
4 2
5 3
6 4
7 5
8 6
dtype: int16 | python/cudf/cudf/core/series.py | dayofweek | jdye64/cudf | 1 | python | @property
def dayofweek(self):
"\n The day of the week with Monday=0, Sunday=6.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.dayofweek\n 0 5\n 1 6\n 2 0\n 3 1\n 4 2\n 5 3\n 6 4\n 7 5\n 8 6\n dtype: int16\n "
return self._get_dt_field('weekday') | @property
def dayofweek(self):
"\n The day of the week with Monday=0, Sunday=6.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.dayofweek\n 0 5\n 1 6\n 2 0\n 3 1\n 4 2\n 5 3\n 6 4\n 7 5\n 8 6\n dtype: int16\n "
return self._get_dt_field('weekday')<|docstring|>The day of the week with Monday=0, Sunday=6.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.dayofweek
0 5
1 6
2 0
3 1
4 2
5 3
6 4
7 5
8 6
dtype: int16<|endoftext|> |
58b927b6d0527bf1fb9c7316f50ec5f1ab7f56241a47f21dcee863b22f836533 | @property
def dayofyear(self):
"\n The day of the year, from 1-365 in non-leap years and\n from 1-366 in leap years.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.dayofyear\n 0 366\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6\n 7 7\n 8 8\n dtype: int16\n "
return self._get_dt_field('day_of_year') | The day of the year, from 1-365 in non-leap years and
from 1-366 in leap years.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.dayofyear
0 366
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
dtype: int16 | python/cudf/cudf/core/series.py | dayofyear | jdye64/cudf | 1 | python | @property
def dayofyear(self):
"\n The day of the year, from 1-365 in non-leap years and\n from 1-366 in leap years.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.dayofyear\n 0 366\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6\n 7 7\n 8 8\n dtype: int16\n "
return self._get_dt_field('day_of_year') | @property
def dayofyear(self):
"\n The day of the year, from 1-365 in non-leap years and\n from 1-366 in leap years.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.dayofyear\n 0 366\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6\n 7 7\n 8 8\n dtype: int16\n "
return self._get_dt_field('day_of_year')<|docstring|>The day of the year, from 1-365 in non-leap years and
from 1-366 in leap years.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.dayofyear
0 366
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
dtype: int16<|endoftext|> |
1111d19c3770949dbbbd306c16f5dd95cdd1b696c3a3d85dd38bc3238e3e1bda | @property
def day_of_year(self):
"\n The day of the year, from 1-365 in non-leap years and\n from 1-366 in leap years.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.day_of_year\n 0 366\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6\n 7 7\n 8 8\n dtype: int16\n "
return self._get_dt_field('day_of_year') | The day of the year, from 1-365 in non-leap years and
from 1-366 in leap years.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.day_of_year
0 366
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
dtype: int16 | python/cudf/cudf/core/series.py | day_of_year | jdye64/cudf | 1 | python | @property
def day_of_year(self):
"\n The day of the year, from 1-365 in non-leap years and\n from 1-366 in leap years.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.day_of_year\n 0 366\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6\n 7 7\n 8 8\n dtype: int16\n "
return self._get_dt_field('day_of_year') | @property
def day_of_year(self):
"\n The day of the year, from 1-365 in non-leap years and\n from 1-366 in leap years.\n\n Examples\n --------\n >>> import pandas as pd\n >>> import cudf\n >>> datetime_series = cudf.Series(pd.date_range('2016-12-31',\n ... '2017-01-08', freq='D'))\n >>> datetime_series\n 0 2016-12-31\n 1 2017-01-01\n 2 2017-01-02\n 3 2017-01-03\n 4 2017-01-04\n 5 2017-01-05\n 6 2017-01-06\n 7 2017-01-07\n 8 2017-01-08\n dtype: datetime64[ns]\n >>> datetime_series.dt.day_of_year\n 0 366\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6\n 7 7\n 8 8\n dtype: int16\n "
return self._get_dt_field('day_of_year')<|docstring|>The day of the year, from 1-365 in non-leap years and
from 1-366 in leap years.
Examples
--------
>>> import pandas as pd
>>> import cudf
>>> datetime_series = cudf.Series(pd.date_range('2016-12-31',
... '2017-01-08', freq='D'))
>>> datetime_series
0 2016-12-31
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
dtype: datetime64[ns]
>>> datetime_series.dt.day_of_year
0 366
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
dtype: int16<|endoftext|> |
8ad1e23ebd830e7b32599564022a85f3565de4cdeb9dffd18ebb47b42fe2021e | @property
def is_leap_year(self):
"\n Boolean indicator if the date belongs to a leap year.\n\n A leap year is a year, which has 366 days (instead of 365) including\n 29th of February as an intercalary day. Leap years are years which are\n multiples of four with the exception of years divisible by 100 but not\n by 400.\n\n Returns\n -------\n Series\n Booleans indicating if dates belong to a leap year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-02-01', end='2013-02-01', freq='1Y'))\n >>> s\n 0 2000-12-31\n 1 2001-12-31\n 2 2002-12-31\n 3 2003-12-31\n 4 2004-12-31\n 5 2005-12-31\n 6 2006-12-31\n 7 2007-12-31\n 8 2008-12-31\n 9 2009-12-31\n 10 2010-12-31\n 11 2011-12-31\n 12 2012-12-31\n dtype: datetime64[ns]\n >>> s.dt.is_leap_year\n 0 True\n 1 False\n 2 False\n 3 False\n 4 True\n 5 False\n 6 False\n 7 False\n 8 True\n 9 False\n 10 False\n 11 False\n 12 True\n dtype: bool\n "
res = libcudf.datetime.is_leap_year(self.series._column).fillna(False)
return Series._from_data(ColumnAccessor({None: res}), index=self.series._index, name=self.series.name) | Boolean indicator if the date belongs to a leap year.
A leap year is a year, which has 366 days (instead of 365) including
29th of February as an intercalary day. Leap years are years which are
multiples of four with the exception of years divisible by 100 but not
by 400.
Returns
-------
Series
Booleans indicating if dates belong to a leap year.
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-02-01', end='2013-02-01', freq='1Y'))
>>> s
0 2000-12-31
1 2001-12-31
2 2002-12-31
3 2003-12-31
4 2004-12-31
5 2005-12-31
6 2006-12-31
7 2007-12-31
8 2008-12-31
9 2009-12-31
10 2010-12-31
11 2011-12-31
12 2012-12-31
dtype: datetime64[ns]
>>> s.dt.is_leap_year
0 True
1 False
2 False
3 False
4 True
5 False
6 False
7 False
8 True
9 False
10 False
11 False
12 True
dtype: bool | python/cudf/cudf/core/series.py | is_leap_year | jdye64/cudf | 1 | python | @property
def is_leap_year(self):
"\n Boolean indicator if the date belongs to a leap year.\n\n A leap year is a year, which has 366 days (instead of 365) including\n 29th of February as an intercalary day. Leap years are years which are\n multiples of four with the exception of years divisible by 100 but not\n by 400.\n\n Returns\n -------\n Series\n Booleans indicating if dates belong to a leap year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-02-01', end='2013-02-01', freq='1Y'))\n >>> s\n 0 2000-12-31\n 1 2001-12-31\n 2 2002-12-31\n 3 2003-12-31\n 4 2004-12-31\n 5 2005-12-31\n 6 2006-12-31\n 7 2007-12-31\n 8 2008-12-31\n 9 2009-12-31\n 10 2010-12-31\n 11 2011-12-31\n 12 2012-12-31\n dtype: datetime64[ns]\n >>> s.dt.is_leap_year\n 0 True\n 1 False\n 2 False\n 3 False\n 4 True\n 5 False\n 6 False\n 7 False\n 8 True\n 9 False\n 10 False\n 11 False\n 12 True\n dtype: bool\n "
res = libcudf.datetime.is_leap_year(self.series._column).fillna(False)
return Series._from_data(ColumnAccessor({None: res}), index=self.series._index, name=self.series.name) | @property
def is_leap_year(self):
"\n Boolean indicator if the date belongs to a leap year.\n\n A leap year is a year, which has 366 days (instead of 365) including\n 29th of February as an intercalary day. Leap years are years which are\n multiples of four with the exception of years divisible by 100 but not\n by 400.\n\n Returns\n -------\n Series\n Booleans indicating if dates belong to a leap year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-02-01', end='2013-02-01', freq='1Y'))\n >>> s\n 0 2000-12-31\n 1 2001-12-31\n 2 2002-12-31\n 3 2003-12-31\n 4 2004-12-31\n 5 2005-12-31\n 6 2006-12-31\n 7 2007-12-31\n 8 2008-12-31\n 9 2009-12-31\n 10 2010-12-31\n 11 2011-12-31\n 12 2012-12-31\n dtype: datetime64[ns]\n >>> s.dt.is_leap_year\n 0 True\n 1 False\n 2 False\n 3 False\n 4 True\n 5 False\n 6 False\n 7 False\n 8 True\n 9 False\n 10 False\n 11 False\n 12 True\n dtype: bool\n "
res = libcudf.datetime.is_leap_year(self.series._column).fillna(False)
return Series._from_data(ColumnAccessor({None: res}), index=self.series._index, name=self.series.name)<|docstring|>Boolean indicator if the date belongs to a leap year.
A leap year is a year, which has 366 days (instead of 365) including
29th of February as an intercalary day. Leap years are years which are
multiples of four with the exception of years divisible by 100 but not
by 400.
Returns
-------
Series
Booleans indicating if dates belong to a leap year.
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-02-01', end='2013-02-01', freq='1Y'))
>>> s
0 2000-12-31
1 2001-12-31
2 2002-12-31
3 2003-12-31
4 2004-12-31
5 2005-12-31
6 2006-12-31
7 2007-12-31
8 2008-12-31
9 2009-12-31
10 2010-12-31
11 2011-12-31
12 2012-12-31
dtype: datetime64[ns]
>>> s.dt.is_leap_year
0 True
1 False
2 False
3 False
4 True
5 False
6 False
7 False
8 True
9 False
10 False
11 False
12 True
dtype: bool<|endoftext|> |
ced48c73f2c297d688a75608371805a8ab7359522b3c3104d100748a819cc2f0 | @property
def quarter(self):
'\n Integer indicator for which quarter of the year the date belongs in.\n\n There are 4 quarters in a year. With the first quarter being from\n January - March, second quarter being April - June, third quarter\n being July - September and fourth quarter being October - December.\n\n Returns\n -------\n Series\n Integer indicating which quarter the date belongs to.\n\n Examples\n -------\n >>> import cudf\n >>> s = cudf.Series(["2020-05-31 08:00:00","1999-12-31 18:40:00"],\n ... dtype="datetime64[ms]")\n >>> s.dt.quarter\n 0 2\n 1 4\n dtype: int8\n '
res = libcudf.datetime.extract_quarter(self.series._column).astype(np.int8)
return Series._from_data({None: res}, index=self.series._index, name=self.series.name) | Integer indicator for which quarter of the year the date belongs in.
There are 4 quarters in a year. With the first quarter being from
January - March, second quarter being April - June, third quarter
being July - September and fourth quarter being October - December.
Returns
-------
Series
Integer indicating which quarter the date belongs to.
Examples
-------
>>> import cudf
>>> s = cudf.Series(["2020-05-31 08:00:00","1999-12-31 18:40:00"],
... dtype="datetime64[ms]")
>>> s.dt.quarter
0 2
1 4
dtype: int8 | python/cudf/cudf/core/series.py | quarter | jdye64/cudf | 1 | python | @property
def quarter(self):
'\n Integer indicator for which quarter of the year the date belongs in.\n\n There are 4 quarters in a year. With the first quarter being from\n January - March, second quarter being April - June, third quarter\n being July - September and fourth quarter being October - December.\n\n Returns\n -------\n Series\n Integer indicating which quarter the date belongs to.\n\n Examples\n -------\n >>> import cudf\n >>> s = cudf.Series(["2020-05-31 08:00:00","1999-12-31 18:40:00"],\n ... dtype="datetime64[ms]")\n >>> s.dt.quarter\n 0 2\n 1 4\n dtype: int8\n '
res = libcudf.datetime.extract_quarter(self.series._column).astype(np.int8)
return Series._from_data({None: res}, index=self.series._index, name=self.series.name) | @property
def quarter(self):
'\n Integer indicator for which quarter of the year the date belongs in.\n\n There are 4 quarters in a year. With the first quarter being from\n January - March, second quarter being April - June, third quarter\n being July - September and fourth quarter being October - December.\n\n Returns\n -------\n Series\n Integer indicating which quarter the date belongs to.\n\n Examples\n -------\n >>> import cudf\n >>> s = cudf.Series(["2020-05-31 08:00:00","1999-12-31 18:40:00"],\n ... dtype="datetime64[ms]")\n >>> s.dt.quarter\n 0 2\n 1 4\n dtype: int8\n '
res = libcudf.datetime.extract_quarter(self.series._column).astype(np.int8)
return Series._from_data({None: res}, index=self.series._index, name=self.series.name)<|docstring|>Integer indicator for which quarter of the year the date belongs in.
There are 4 quarters in a year. With the first quarter being from
January - March, second quarter being April - June, third quarter
being July - September and fourth quarter being October - December.
Returns
-------
Series
Integer indicating which quarter the date belongs to.
Examples
-------
>>> import cudf
>>> s = cudf.Series(["2020-05-31 08:00:00","1999-12-31 18:40:00"],
... dtype="datetime64[ms]")
>>> s.dt.quarter
0 2
1 4
dtype: int8<|endoftext|> |
00b878b047892f056dae2c3880f81b33f109fd9e82d94784ce910e3558d155ec | @property
def is_month_start(self):
'\n Booleans indicating if dates are the first day of the month.\n '
return (self.day == 1).fillna(False) | Booleans indicating if dates are the first day of the month. | python/cudf/cudf/core/series.py | is_month_start | jdye64/cudf | 1 | python | @property
def is_month_start(self):
'\n \n '
return (self.day == 1).fillna(False) | @property
def is_month_start(self):
'\n \n '
return (self.day == 1).fillna(False)<|docstring|>Booleans indicating if dates are the first day of the month.<|endoftext|> |
f25437295772eb933b8109107ff3232aab4b2abd7ae8a1b93162e7e807f5ddb4 | @property
def days_in_month(self):
"\n Get the total number of days in the month that the date falls on.\n\n Returns\n -------\n Series\n Integers representing the number of days in month\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-08-01', end='2001-08-01', freq='1M'))\n >>> s\n 0 2000-08-31\n 1 2000-09-30\n 2 2000-10-31\n 3 2000-11-30\n 4 2000-12-31\n 5 2001-01-31\n 6 2001-02-28\n 7 2001-03-31\n 8 2001-04-30\n 9 2001-05-31\n 10 2001-06-30\n 11 2001-07-31\n dtype: datetime64[ns]\n >>> s.dt.days_in_month\n 0 31\n 1 30\n 2 31\n 3 30\n 4 31\n 5 31\n 6 28\n 7 31\n 8 30\n 9 31\n 10 30\n 11 31\n dtype: int16\n "
res = libcudf.datetime.days_in_month(self.series._column)
return Series._from_data(ColumnAccessor({None: res}), index=self.series._index, name=self.series.name) | Get the total number of days in the month that the date falls on.
Returns
-------
Series
Integers representing the number of days in month
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-08-01', end='2001-08-01', freq='1M'))
>>> s
0 2000-08-31
1 2000-09-30
2 2000-10-31
3 2000-11-30
4 2000-12-31
5 2001-01-31
6 2001-02-28
7 2001-03-31
8 2001-04-30
9 2001-05-31
10 2001-06-30
11 2001-07-31
dtype: datetime64[ns]
>>> s.dt.days_in_month
0 31
1 30
2 31
3 30
4 31
5 31
6 28
7 31
8 30
9 31
10 30
11 31
dtype: int16 | python/cudf/cudf/core/series.py | days_in_month | jdye64/cudf | 1 | python | @property
def days_in_month(self):
"\n Get the total number of days in the month that the date falls on.\n\n Returns\n -------\n Series\n Integers representing the number of days in month\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-08-01', end='2001-08-01', freq='1M'))\n >>> s\n 0 2000-08-31\n 1 2000-09-30\n 2 2000-10-31\n 3 2000-11-30\n 4 2000-12-31\n 5 2001-01-31\n 6 2001-02-28\n 7 2001-03-31\n 8 2001-04-30\n 9 2001-05-31\n 10 2001-06-30\n 11 2001-07-31\n dtype: datetime64[ns]\n >>> s.dt.days_in_month\n 0 31\n 1 30\n 2 31\n 3 30\n 4 31\n 5 31\n 6 28\n 7 31\n 8 30\n 9 31\n 10 30\n 11 31\n dtype: int16\n "
res = libcudf.datetime.days_in_month(self.series._column)
return Series._from_data(ColumnAccessor({None: res}), index=self.series._index, name=self.series.name) | @property
def days_in_month(self):
"\n Get the total number of days in the month that the date falls on.\n\n Returns\n -------\n Series\n Integers representing the number of days in month\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-08-01', end='2001-08-01', freq='1M'))\n >>> s\n 0 2000-08-31\n 1 2000-09-30\n 2 2000-10-31\n 3 2000-11-30\n 4 2000-12-31\n 5 2001-01-31\n 6 2001-02-28\n 7 2001-03-31\n 8 2001-04-30\n 9 2001-05-31\n 10 2001-06-30\n 11 2001-07-31\n dtype: datetime64[ns]\n >>> s.dt.days_in_month\n 0 31\n 1 30\n 2 31\n 3 30\n 4 31\n 5 31\n 6 28\n 7 31\n 8 30\n 9 31\n 10 30\n 11 31\n dtype: int16\n "
res = libcudf.datetime.days_in_month(self.series._column)
return Series._from_data(ColumnAccessor({None: res}), index=self.series._index, name=self.series.name)<|docstring|>Get the total number of days in the month that the date falls on.
Returns
-------
Series
Integers representing the number of days in month
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-08-01', end='2001-08-01', freq='1M'))
>>> s
0 2000-08-31
1 2000-09-30
2 2000-10-31
3 2000-11-30
4 2000-12-31
5 2001-01-31
6 2001-02-28
7 2001-03-31
8 2001-04-30
9 2001-05-31
10 2001-06-30
11 2001-07-31
dtype: datetime64[ns]
>>> s.dt.days_in_month
0 31
1 30
2 31
3 30
4 31
5 31
6 28
7 31
8 30
9 31
10 30
11 31
dtype: int16<|endoftext|> |
4ef645dc0f73999a89c1bdb85378cc1452034f95cdad954f95ee8fce183e9e72 | @property
def is_month_end(self):
"\n Boolean indicator if the date is the last day of the month.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the last day of the month.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-08-26', end='2000-09-03', freq='1D'))\n >>> s\n 0 2000-08-26\n 1 2000-08-27\n 2 2000-08-28\n 3 2000-08-29\n 4 2000-08-30\n 5 2000-08-31\n 6 2000-09-01\n 7 2000-09-02\n 8 2000-09-03\n dtype: datetime64[ns]\n >>> s.dt.is_month_end\n 0 False\n 1 False\n 2 False\n 3 False\n 4 False\n 5 True\n 6 False\n 7 False\n 8 False\n dtype: bool\n "
last_day = libcudf.datetime.last_day_of_month(self.series._column)
last_day = Series._from_data(ColumnAccessor({None: last_day}), index=self.series._index, name=self.series.name)
return (self.day == last_day.dt.day).fillna(False) | Boolean indicator if the date is the last day of the month.
Returns
-------
Series
Booleans indicating if dates are the last day of the month.
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-08-26', end='2000-09-03', freq='1D'))
>>> s
0 2000-08-26
1 2000-08-27
2 2000-08-28
3 2000-08-29
4 2000-08-30
5 2000-08-31
6 2000-09-01
7 2000-09-02
8 2000-09-03
dtype: datetime64[ns]
>>> s.dt.is_month_end
0 False
1 False
2 False
3 False
4 False
5 True
6 False
7 False
8 False
dtype: bool | python/cudf/cudf/core/series.py | is_month_end | jdye64/cudf | 1 | python | @property
def is_month_end(self):
"\n Boolean indicator if the date is the last day of the month.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the last day of the month.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-08-26', end='2000-09-03', freq='1D'))\n >>> s\n 0 2000-08-26\n 1 2000-08-27\n 2 2000-08-28\n 3 2000-08-29\n 4 2000-08-30\n 5 2000-08-31\n 6 2000-09-01\n 7 2000-09-02\n 8 2000-09-03\n dtype: datetime64[ns]\n >>> s.dt.is_month_end\n 0 False\n 1 False\n 2 False\n 3 False\n 4 False\n 5 True\n 6 False\n 7 False\n 8 False\n dtype: bool\n "
last_day = libcudf.datetime.last_day_of_month(self.series._column)
last_day = Series._from_data(ColumnAccessor({None: last_day}), index=self.series._index, name=self.series.name)
return (self.day == last_day.dt.day).fillna(False) | @property
def is_month_end(self):
"\n Boolean indicator if the date is the last day of the month.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the last day of the month.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-08-26', end='2000-09-03', freq='1D'))\n >>> s\n 0 2000-08-26\n 1 2000-08-27\n 2 2000-08-28\n 3 2000-08-29\n 4 2000-08-30\n 5 2000-08-31\n 6 2000-09-01\n 7 2000-09-02\n 8 2000-09-03\n dtype: datetime64[ns]\n >>> s.dt.is_month_end\n 0 False\n 1 False\n 2 False\n 3 False\n 4 False\n 5 True\n 6 False\n 7 False\n 8 False\n dtype: bool\n "
last_day = libcudf.datetime.last_day_of_month(self.series._column)
last_day = Series._from_data(ColumnAccessor({None: last_day}), index=self.series._index, name=self.series.name)
return (self.day == last_day.dt.day).fillna(False)<|docstring|>Boolean indicator if the date is the last day of the month.
Returns
-------
Series
Booleans indicating if dates are the last day of the month.
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-08-26', end='2000-09-03', freq='1D'))
>>> s
0 2000-08-26
1 2000-08-27
2 2000-08-28
3 2000-08-29
4 2000-08-30
5 2000-08-31
6 2000-09-01
7 2000-09-02
8 2000-09-03
dtype: datetime64[ns]
>>> s.dt.is_month_end
0 False
1 False
2 False
3 False
4 False
5 True
6 False
7 False
8 False
dtype: bool<|endoftext|> |
4c31c582e71ce1edbfe8ee6445cec85fc8d61acd7dd9be56d2e4fab3776016ed | @property
def is_quarter_start(self):
"\n Boolean indicator if the date is the first day of a quarter.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the begining of a quarter\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))\n >>> s\n 0 2000-09-26\n 1 2000-09-27\n 2 2000-09-28\n 3 2000-09-29\n 4 2000-09-30\n 5 2000-10-01\n 6 2000-10-02\n 7 2000-10-03\n dtype: datetime64[ns]\n >>> s.dt.is_quarter_start\n 0 False\n 1 False\n 2 False\n 3 False\n 4 False\n 5 True\n 6 False\n 7 False\n dtype: bool\n "
day = self.series._column.get_dt_field('day')
first_month = self.series._column.get_dt_field('month').isin([1, 4, 7, 10])
result = ((day == cudf.Scalar(1)) & first_month).fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name) | Boolean indicator if the date is the first day of a quarter.
Returns
-------
Series
Booleans indicating if dates are the begining of a quarter
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))
>>> s
0 2000-09-26
1 2000-09-27
2 2000-09-28
3 2000-09-29
4 2000-09-30
5 2000-10-01
6 2000-10-02
7 2000-10-03
dtype: datetime64[ns]
>>> s.dt.is_quarter_start
0 False
1 False
2 False
3 False
4 False
5 True
6 False
7 False
dtype: bool | python/cudf/cudf/core/series.py | is_quarter_start | jdye64/cudf | 1 | python | @property
def is_quarter_start(self):
"\n Boolean indicator if the date is the first day of a quarter.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the begining of a quarter\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))\n >>> s\n 0 2000-09-26\n 1 2000-09-27\n 2 2000-09-28\n 3 2000-09-29\n 4 2000-09-30\n 5 2000-10-01\n 6 2000-10-02\n 7 2000-10-03\n dtype: datetime64[ns]\n >>> s.dt.is_quarter_start\n 0 False\n 1 False\n 2 False\n 3 False\n 4 False\n 5 True\n 6 False\n 7 False\n dtype: bool\n "
day = self.series._column.get_dt_field('day')
first_month = self.series._column.get_dt_field('month').isin([1, 4, 7, 10])
result = ((day == cudf.Scalar(1)) & first_month).fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name) | @property
def is_quarter_start(self):
"\n Boolean indicator if the date is the first day of a quarter.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the begining of a quarter\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))\n >>> s\n 0 2000-09-26\n 1 2000-09-27\n 2 2000-09-28\n 3 2000-09-29\n 4 2000-09-30\n 5 2000-10-01\n 6 2000-10-02\n 7 2000-10-03\n dtype: datetime64[ns]\n >>> s.dt.is_quarter_start\n 0 False\n 1 False\n 2 False\n 3 False\n 4 False\n 5 True\n 6 False\n 7 False\n dtype: bool\n "
day = self.series._column.get_dt_field('day')
first_month = self.series._column.get_dt_field('month').isin([1, 4, 7, 10])
result = ((day == cudf.Scalar(1)) & first_month).fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name)<|docstring|>Boolean indicator if the date is the first day of a quarter.
Returns
-------
Series
Booleans indicating if dates are the begining of a quarter
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))
>>> s
0 2000-09-26
1 2000-09-27
2 2000-09-28
3 2000-09-29
4 2000-09-30
5 2000-10-01
6 2000-10-02
7 2000-10-03
dtype: datetime64[ns]
>>> s.dt.is_quarter_start
0 False
1 False
2 False
3 False
4 False
5 True
6 False
7 False
dtype: bool<|endoftext|> |
ec4733036f278e5620942ff63355da0ce217006089523716f12e281af6add9e2 | @property
def is_quarter_end(self):
"\n Boolean indicator if the date is the last day of a quarter.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the end of a quarter\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))\n >>> s\n 0 2000-09-26\n 1 2000-09-27\n 2 2000-09-28\n 3 2000-09-29\n 4 2000-09-30\n 5 2000-10-01\n 6 2000-10-02\n 7 2000-10-03\n dtype: datetime64[ns]\n >>> s.dt.is_quarter_end\n 0 False\n 1 False\n 2 False\n 3 False\n 4 True\n 5 False\n 6 False\n 7 False\n dtype: bool\n "
day = self.series._column.get_dt_field('day')
last_day = libcudf.datetime.last_day_of_month(self.series._column)
last_day = last_day.get_dt_field('day')
last_month = self.series._column.get_dt_field('month').isin([3, 6, 9, 12])
result = ((day == last_day) & last_month).fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name) | Boolean indicator if the date is the last day of a quarter.
Returns
-------
Series
Booleans indicating if dates are the end of a quarter
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))
>>> s
0 2000-09-26
1 2000-09-27
2 2000-09-28
3 2000-09-29
4 2000-09-30
5 2000-10-01
6 2000-10-02
7 2000-10-03
dtype: datetime64[ns]
>>> s.dt.is_quarter_end
0 False
1 False
2 False
3 False
4 True
5 False
6 False
7 False
dtype: bool | python/cudf/cudf/core/series.py | is_quarter_end | jdye64/cudf | 1 | python | @property
def is_quarter_end(self):
"\n Boolean indicator if the date is the last day of a quarter.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the end of a quarter\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))\n >>> s\n 0 2000-09-26\n 1 2000-09-27\n 2 2000-09-28\n 3 2000-09-29\n 4 2000-09-30\n 5 2000-10-01\n 6 2000-10-02\n 7 2000-10-03\n dtype: datetime64[ns]\n >>> s.dt.is_quarter_end\n 0 False\n 1 False\n 2 False\n 3 False\n 4 True\n 5 False\n 6 False\n 7 False\n dtype: bool\n "
day = self.series._column.get_dt_field('day')
last_day = libcudf.datetime.last_day_of_month(self.series._column)
last_day = last_day.get_dt_field('day')
last_month = self.series._column.get_dt_field('month').isin([3, 6, 9, 12])
result = ((day == last_day) & last_month).fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name) | @property
def is_quarter_end(self):
"\n Boolean indicator if the date is the last day of a quarter.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the end of a quarter\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(\n ... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))\n >>> s\n 0 2000-09-26\n 1 2000-09-27\n 2 2000-09-28\n 3 2000-09-29\n 4 2000-09-30\n 5 2000-10-01\n 6 2000-10-02\n 7 2000-10-03\n dtype: datetime64[ns]\n >>> s.dt.is_quarter_end\n 0 False\n 1 False\n 2 False\n 3 False\n 4 True\n 5 False\n 6 False\n 7 False\n dtype: bool\n "
day = self.series._column.get_dt_field('day')
last_day = libcudf.datetime.last_day_of_month(self.series._column)
last_day = last_day.get_dt_field('day')
last_month = self.series._column.get_dt_field('month').isin([3, 6, 9, 12])
result = ((day == last_day) & last_month).fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name)<|docstring|>Boolean indicator if the date is the last day of a quarter.
Returns
-------
Series
Booleans indicating if dates are the end of a quarter
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(
... pd.date_range(start='2000-09-26', end='2000-10-03', freq='1D'))
>>> s
0 2000-09-26
1 2000-09-27
2 2000-09-28
3 2000-09-29
4 2000-09-30
5 2000-10-01
6 2000-10-02
7 2000-10-03
dtype: datetime64[ns]
>>> s.dt.is_quarter_end
0 False
1 False
2 False
3 False
4 True
5 False
6 False
7 False
dtype: bool<|endoftext|> |
9e0b20f2c9b161ac88128a60a4ac47f8608a460fbfbc7a0c6edf7cafb8e88461 | @property
def is_year_start(self):
'\n Boolean indicator if the date is the first day of the year.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the first day of the year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(pd.date_range("2017-12-30", periods=3))\n >>> dates\n 0 2017-12-30\n 1 2017-12-31\n 2 2018-01-01\n dtype: datetime64[ns]\n >>> dates.dt.is_year_start\n 0 False\n 1 False\n 2 True\n dtype: bool\n '
outcol = (self.series._column.get_dt_field('day_of_year') == cudf.Scalar(1))
return Series._from_data({None: outcol.fillna(False)}, index=self.series._index, name=self.series.name) | Boolean indicator if the date is the first day of the year.
Returns
-------
Series
Booleans indicating if dates are the first day of the year.
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0 2017-12-30
1 2017-12-31
2 2018-01-01
dtype: datetime64[ns]
>>> dates.dt.is_year_start
0 False
1 False
2 True
dtype: bool | python/cudf/cudf/core/series.py | is_year_start | jdye64/cudf | 1 | python | @property
def is_year_start(self):
'\n Boolean indicator if the date is the first day of the year.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the first day of the year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(pd.date_range("2017-12-30", periods=3))\n >>> dates\n 0 2017-12-30\n 1 2017-12-31\n 2 2018-01-01\n dtype: datetime64[ns]\n >>> dates.dt.is_year_start\n 0 False\n 1 False\n 2 True\n dtype: bool\n '
outcol = (self.series._column.get_dt_field('day_of_year') == cudf.Scalar(1))
return Series._from_data({None: outcol.fillna(False)}, index=self.series._index, name=self.series.name) | @property
def is_year_start(self):
'\n Boolean indicator if the date is the first day of the year.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the first day of the year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> s = cudf.Series(pd.date_range("2017-12-30", periods=3))\n >>> dates\n 0 2017-12-30\n 1 2017-12-31\n 2 2018-01-01\n dtype: datetime64[ns]\n >>> dates.dt.is_year_start\n 0 False\n 1 False\n 2 True\n dtype: bool\n '
outcol = (self.series._column.get_dt_field('day_of_year') == cudf.Scalar(1))
return Series._from_data({None: outcol.fillna(False)}, index=self.series._index, name=self.series.name)<|docstring|>Boolean indicator if the date is the first day of the year.
Returns
-------
Series
Booleans indicating if dates are the first day of the year.
Example
-------
>>> import pandas as pd, cudf
>>> s = cudf.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0 2017-12-30
1 2017-12-31
2 2018-01-01
dtype: datetime64[ns]
>>> dates.dt.is_year_start
0 False
1 False
2 True
dtype: bool<|endoftext|> |
f3eb07485e1f09854e616428290c0982b5383ffe9820efeb7fcaeeab42d3fa49 | @property
def is_year_end(self):
'\n Boolean indicator if the date is the last day of the year.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the last day of the year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> dates = cudf.Series(pd.date_range("2017-12-30", periods=3))\n >>> dates\n 0 2017-12-30\n 1 2017-12-31\n 2 2018-01-01\n dtype: datetime64[ns]\n >>> dates.dt.is_year_end\n 0 False\n 1 True\n 2 False\n dtype: bool\n '
day_of_year = self.series._column.get_dt_field('day_of_year')
leap_dates = libcudf.datetime.is_leap_year(self.series._column)
leap = (day_of_year == cudf.Scalar(366))
non_leap = (day_of_year == cudf.Scalar(365))
result = cudf._lib.copying.copy_if_else(leap, non_leap, leap_dates)
result = result.fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name) | Boolean indicator if the date is the last day of the year.
Returns
-------
Series
Booleans indicating if dates are the last day of the year.
Example
-------
>>> import pandas as pd, cudf
>>> dates = cudf.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0 2017-12-30
1 2017-12-31
2 2018-01-01
dtype: datetime64[ns]
>>> dates.dt.is_year_end
0 False
1 True
2 False
dtype: bool | python/cudf/cudf/core/series.py | is_year_end | jdye64/cudf | 1 | python | @property
def is_year_end(self):
'\n Boolean indicator if the date is the last day of the year.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the last day of the year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> dates = cudf.Series(pd.date_range("2017-12-30", periods=3))\n >>> dates\n 0 2017-12-30\n 1 2017-12-31\n 2 2018-01-01\n dtype: datetime64[ns]\n >>> dates.dt.is_year_end\n 0 False\n 1 True\n 2 False\n dtype: bool\n '
day_of_year = self.series._column.get_dt_field('day_of_year')
leap_dates = libcudf.datetime.is_leap_year(self.series._column)
leap = (day_of_year == cudf.Scalar(366))
non_leap = (day_of_year == cudf.Scalar(365))
result = cudf._lib.copying.copy_if_else(leap, non_leap, leap_dates)
result = result.fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name) | @property
def is_year_end(self):
'\n Boolean indicator if the date is the last day of the year.\n\n Returns\n -------\n Series\n Booleans indicating if dates are the last day of the year.\n\n Example\n -------\n >>> import pandas as pd, cudf\n >>> dates = cudf.Series(pd.date_range("2017-12-30", periods=3))\n >>> dates\n 0 2017-12-30\n 1 2017-12-31\n 2 2018-01-01\n dtype: datetime64[ns]\n >>> dates.dt.is_year_end\n 0 False\n 1 True\n 2 False\n dtype: bool\n '
day_of_year = self.series._column.get_dt_field('day_of_year')
leap_dates = libcudf.datetime.is_leap_year(self.series._column)
leap = (day_of_year == cudf.Scalar(366))
non_leap = (day_of_year == cudf.Scalar(365))
result = cudf._lib.copying.copy_if_else(leap, non_leap, leap_dates)
result = result.fillna(False)
return Series._from_data({None: result}, index=self.series._index, name=self.series.name)<|docstring|>Boolean indicator if the date is the last day of the year.
Returns
-------
Series
Booleans indicating if dates are the last day of the year.
Example
-------
>>> import pandas as pd, cudf
>>> dates = cudf.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0 2017-12-30
1 2017-12-31
2 2018-01-01
dtype: datetime64[ns]
>>> dates.dt.is_year_end
0 False
1 True
2 False
dtype: bool<|endoftext|> |
384c0bdb6662aecd16f663bd84dbbc28e721aabd4a60615e31e5f706f5776bf5 | def strftime(self, date_format, *args, **kwargs):
'\n Convert to Series using specified ``date_format``.\n\n Return a Series of formatted strings specified by ``date_format``,\n which supports the same string format as the python standard library.\n Details of the string format can be found in `python string format doc\n <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`_.\n\n Parameters\n ----------\n date_format : str\n Date format string (e.g. “%Y-%m-%d”).\n\n Returns\n -------\n Series\n Series of formatted strings.\n\n Notes\n -----\n\n The following date format identifiers are not yet supported: ``%a``,\n ``%A``, ``%w``, ``%b``, ``%B``, ``%U``, ``%W``, ``%c``, ``%x``,\n ``%X``, ``%G``, ``%u``, ``%V``\n\n Examples\n --------\n >>> import cudf\n >>> import pandas as pd\n >>> weekday_series = cudf.Series(pd.date_range("2000-01-01", periods=3,\n ... freq="q"))\n >>> weekday_series.dt.strftime("%Y-%m-%d")\n >>> weekday_series\n 0 2000-03-31\n 1 2000-06-30\n 2 2000-09-30\n dtype: datetime64[ns]\n 0 2000-03-31\n 1 2000-06-30\n 2 2000-09-30\n dtype: object\n >>> weekday_series.dt.strftime("%Y %d %m")\n 0 2000 31 03\n 1 2000 30 06\n 2 2000 30 09\n dtype: object\n >>> weekday_series.dt.strftime("%Y / %d / %m")\n 0 2000 / 31 / 03\n 1 2000 / 30 / 06\n 2 2000 / 30 / 09\n dtype: object\n '
if (not isinstance(date_format, str)):
raise TypeError(f"'date_format' must be str, not {type(date_format)}")
not_implemented_formats = {'%a', '%A', '%w', '%b', '%B', '%U', '%W', '%c', '%x', '%X', '%G', '%u', '%V'}
for d_format in not_implemented_formats:
if (d_format in date_format):
raise NotImplementedError(f'{d_format} date-time format is not supported yet, Please follow this issue https://github.com/rapidsai/cudf/issues/5991 for tracking purposes.')
str_col = self.series._column.as_string_column(dtype='str', format=date_format)
return Series(data=str_col, index=self.series._index, name=self.series.name) | Convert to Series using specified ``date_format``.
Return a Series of formatted strings specified by ``date_format``,
which supports the same string format as the python standard library.
Details of the string format can be found in `python string format doc
<https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`_.
Parameters
----------
date_format : str
Date format string (e.g. “%Y-%m-%d”).
Returns
-------
Series
Series of formatted strings.
Notes
-----
The following date format identifiers are not yet supported: ``%a``,
``%A``, ``%w``, ``%b``, ``%B``, ``%U``, ``%W``, ``%c``, ``%x``,
``%X``, ``%G``, ``%u``, ``%V``
Examples
--------
>>> import cudf
>>> import pandas as pd
>>> weekday_series = cudf.Series(pd.date_range("2000-01-01", periods=3,
... freq="q"))
>>> weekday_series.dt.strftime("%Y-%m-%d")
>>> weekday_series
0 2000-03-31
1 2000-06-30
2 2000-09-30
dtype: datetime64[ns]
0 2000-03-31
1 2000-06-30
2 2000-09-30
dtype: object
>>> weekday_series.dt.strftime("%Y %d %m")
0 2000 31 03
1 2000 30 06
2 2000 30 09
dtype: object
>>> weekday_series.dt.strftime("%Y / %d / %m")
0 2000 / 31 / 03
1 2000 / 30 / 06
2 2000 / 30 / 09
dtype: object | python/cudf/cudf/core/series.py | strftime | jdye64/cudf | 1 | python | def strftime(self, date_format, *args, **kwargs):
'\n Convert to Series using specified ``date_format``.\n\n Return a Series of formatted strings specified by ``date_format``,\n which supports the same string format as the python standard library.\n Details of the string format can be found in `python string format doc\n <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`_.\n\n Parameters\n ----------\n date_format : str\n Date format string (e.g. “%Y-%m-%d”).\n\n Returns\n -------\n Series\n Series of formatted strings.\n\n Notes\n -----\n\n The following date format identifiers are not yet supported: ``%a``,\n ``%A``, ``%w``, ``%b``, ``%B``, ``%U``, ``%W``, ``%c``, ``%x``,\n ``%X``, ``%G``, ``%u``, ``%V``\n\n Examples\n --------\n >>> import cudf\n >>> import pandas as pd\n >>> weekday_series = cudf.Series(pd.date_range("2000-01-01", periods=3,\n ... freq="q"))\n >>> weekday_series.dt.strftime("%Y-%m-%d")\n >>> weekday_series\n 0 2000-03-31\n 1 2000-06-30\n 2 2000-09-30\n dtype: datetime64[ns]\n 0 2000-03-31\n 1 2000-06-30\n 2 2000-09-30\n dtype: object\n >>> weekday_series.dt.strftime("%Y %d %m")\n 0 2000 31 03\n 1 2000 30 06\n 2 2000 30 09\n dtype: object\n >>> weekday_series.dt.strftime("%Y / %d / %m")\n 0 2000 / 31 / 03\n 1 2000 / 30 / 06\n 2 2000 / 30 / 09\n dtype: object\n '
if (not isinstance(date_format, str)):
raise TypeError(f"'date_format' must be str, not {type(date_format)}")
not_implemented_formats = {'%a', '%A', '%w', '%b', '%B', '%U', '%W', '%c', '%x', '%X', '%G', '%u', '%V'}
for d_format in not_implemented_formats:
if (d_format in date_format):
raise NotImplementedError(f'{d_format} date-time format is not supported yet, Please follow this issue https://github.com/rapidsai/cudf/issues/5991 for tracking purposes.')
str_col = self.series._column.as_string_column(dtype='str', format=date_format)
return Series(data=str_col, index=self.series._index, name=self.series.name) | def strftime(self, date_format, *args, **kwargs):
'\n Convert to Series using specified ``date_format``.\n\n Return a Series of formatted strings specified by ``date_format``,\n which supports the same string format as the python standard library.\n Details of the string format can be found in `python string format doc\n <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`_.\n\n Parameters\n ----------\n date_format : str\n Date format string (e.g. “%Y-%m-%d”).\n\n Returns\n -------\n Series\n Series of formatted strings.\n\n Notes\n -----\n\n The following date format identifiers are not yet supported: ``%a``,\n ``%A``, ``%w``, ``%b``, ``%B``, ``%U``, ``%W``, ``%c``, ``%x``,\n ``%X``, ``%G``, ``%u``, ``%V``\n\n Examples\n --------\n >>> import cudf\n >>> import pandas as pd\n >>> weekday_series = cudf.Series(pd.date_range("2000-01-01", periods=3,\n ... freq="q"))\n >>> weekday_series.dt.strftime("%Y-%m-%d")\n >>> weekday_series\n 0 2000-03-31\n 1 2000-06-30\n 2 2000-09-30\n dtype: datetime64[ns]\n 0 2000-03-31\n 1 2000-06-30\n 2 2000-09-30\n dtype: object\n >>> weekday_series.dt.strftime("%Y %d %m")\n 0 2000 31 03\n 1 2000 30 06\n 2 2000 30 09\n dtype: object\n >>> weekday_series.dt.strftime("%Y / %d / %m")\n 0 2000 / 31 / 03\n 1 2000 / 30 / 06\n 2 2000 / 30 / 09\n dtype: object\n '
if (not isinstance(date_format, str)):
raise TypeError(f"'date_format' must be str, not {type(date_format)}")
not_implemented_formats = {'%a', '%A', '%w', '%b', '%B', '%U', '%W', '%c', '%x', '%X', '%G', '%u', '%V'}
for d_format in not_implemented_formats:
if (d_format in date_format):
raise NotImplementedError(f'{d_format} date-time format is not supported yet, Please follow this issue https://github.com/rapidsai/cudf/issues/5991 for tracking purposes.')
str_col = self.series._column.as_string_column(dtype='str', format=date_format)
return Series(data=str_col, index=self.series._index, name=self.series.name)<|docstring|>Convert to Series using specified ``date_format``.
Return a Series of formatted strings specified by ``date_format``,
which supports the same string format as the python standard library.
Details of the string format can be found in `python string format doc
<https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`_.
Parameters
----------
date_format : str
Date format string (e.g. “%Y-%m-%d”).
Returns
-------
Series
Series of formatted strings.
Notes
-----
The following date format identifiers are not yet supported: ``%a``,
``%A``, ``%w``, ``%b``, ``%B``, ``%U``, ``%W``, ``%c``, ``%x``,
``%X``, ``%G``, ``%u``, ``%V``
Examples
--------
>>> import cudf
>>> import pandas as pd
>>> weekday_series = cudf.Series(pd.date_range("2000-01-01", periods=3,
... freq="q"))
>>> weekday_series.dt.strftime("%Y-%m-%d")
>>> weekday_series
0 2000-03-31
1 2000-06-30
2 2000-09-30
dtype: datetime64[ns]
0 2000-03-31
1 2000-06-30
2 2000-09-30
dtype: object
>>> weekday_series.dt.strftime("%Y %d %m")
0 2000 31 03
1 2000 30 06
2 2000 30 09
dtype: object
>>> weekday_series.dt.strftime("%Y / %d / %m")
0 2000 / 31 / 03
1 2000 / 30 / 06
2 2000 / 30 / 09
dtype: object<|endoftext|> |
184883c45a418134ef9276b5447bbdf70ce37703d1f862b257357a0a2e65d3b1 | @property
def days(self):
"\n Number of days.\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.days\n 0 141\n 1 14\n 2 13000\n 3 0\n 4 37\n dtype: int64\n "
return self._get_td_field('days') | Number of days.
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.days
0 141
1 14
2 13000
3 0
4 37
dtype: int64 | python/cudf/cudf/core/series.py | days | jdye64/cudf | 1 | python | @property
def days(self):
"\n Number of days.\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.days\n 0 141\n 1 14\n 2 13000\n 3 0\n 4 37\n dtype: int64\n "
return self._get_td_field('days') | @property
def days(self):
"\n Number of days.\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.days\n 0 141\n 1 14\n 2 13000\n 3 0\n 4 37\n dtype: int64\n "
return self._get_td_field('days')<|docstring|>Number of days.
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.days
0 141
1 14
2 13000
3 0
4 37
dtype: int64<|endoftext|> |
a4d50b8b8ed15c003c94ffd7d3f2927cca1858bf69784f3a36dd8e5b71186572 | @property
def seconds(self):
"\n Number of seconds (>= 0 and less than 1 day).\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.seconds\n 0 48912\n 1 21631\n 2 36768\n 3 2135\n 4 47534\n dtype: int64\n >>> s.dt.microseconds\n 0 123000\n 1 231000\n 2 712000\n 3 656000\n 4 234000\n dtype: int64\n "
return self._get_td_field('seconds') | Number of seconds (>= 0 and less than 1 day).
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.seconds
0 48912
1 21631
2 36768
3 2135
4 47534
dtype: int64
>>> s.dt.microseconds
0 123000
1 231000
2 712000
3 656000
4 234000
dtype: int64 | python/cudf/cudf/core/series.py | seconds | jdye64/cudf | 1 | python | @property
def seconds(self):
"\n Number of seconds (>= 0 and less than 1 day).\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.seconds\n 0 48912\n 1 21631\n 2 36768\n 3 2135\n 4 47534\n dtype: int64\n >>> s.dt.microseconds\n 0 123000\n 1 231000\n 2 712000\n 3 656000\n 4 234000\n dtype: int64\n "
return self._get_td_field('seconds') | @property
def seconds(self):
"\n Number of seconds (>= 0 and less than 1 day).\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.seconds\n 0 48912\n 1 21631\n 2 36768\n 3 2135\n 4 47534\n dtype: int64\n >>> s.dt.microseconds\n 0 123000\n 1 231000\n 2 712000\n 3 656000\n 4 234000\n dtype: int64\n "
return self._get_td_field('seconds')<|docstring|>Number of seconds (>= 0 and less than 1 day).
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.seconds
0 48912
1 21631
2 36768
3 2135
4 47534
dtype: int64
>>> s.dt.microseconds
0 123000
1 231000
2 712000
3 656000
4 234000
dtype: int64<|endoftext|> |
fa6823b22e03ce24eceaf4583cf7faa6c4e19549e876893849a43ccd4c13c02a | @property
def microseconds(self):
"\n Number of microseconds (>= 0 and less than 1 second).\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.microseconds\n 0 123000\n 1 231000\n 2 712000\n 3 656000\n 4 234000\n dtype: int64\n "
return self._get_td_field('microseconds') | Number of microseconds (>= 0 and less than 1 second).
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.microseconds
0 123000
1 231000
2 712000
3 656000
4 234000
dtype: int64 | python/cudf/cudf/core/series.py | microseconds | jdye64/cudf | 1 | python | @property
def microseconds(self):
"\n Number of microseconds (>= 0 and less than 1 second).\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.microseconds\n 0 123000\n 1 231000\n 2 712000\n 3 656000\n 4 234000\n dtype: int64\n "
return self._get_td_field('microseconds') | @property
def microseconds(self):
"\n Number of microseconds (>= 0 and less than 1 second).\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.microseconds\n 0 123000\n 1 231000\n 2 712000\n 3 656000\n 4 234000\n dtype: int64\n "
return self._get_td_field('microseconds')<|docstring|>Number of microseconds (>= 0 and less than 1 second).
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.microseconds
0 123000
1 231000
2 712000
3 656000
4 234000
dtype: int64<|endoftext|> |
12d75a9edd4eebc0e1dea120abe0d299b41bc3748d9f2383435496dc7df2cd8f | @property
def nanoseconds(self):
"\n Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ns]')\n >>> s\n 0 00:00:12.231312123\n 1 00:00:01.231231231\n 2 00:18:43.236768712\n 3 00:00:00.002135656\n 4 00:00:03.244334234\n dtype: timedelta64[ns]\n >>> s.dt.nanoseconds\n 0 123\n 1 231\n 2 712\n 3 656\n 4 234\n dtype: int64\n "
return self._get_td_field('nanoseconds') | Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ns]')
>>> s
0 00:00:12.231312123
1 00:00:01.231231231
2 00:18:43.236768712
3 00:00:00.002135656
4 00:00:03.244334234
dtype: timedelta64[ns]
>>> s.dt.nanoseconds
0 123
1 231
2 712
3 656
4 234
dtype: int64 | python/cudf/cudf/core/series.py | nanoseconds | jdye64/cudf | 1 | python | @property
def nanoseconds(self):
"\n Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ns]')\n >>> s\n 0 00:00:12.231312123\n 1 00:00:01.231231231\n 2 00:18:43.236768712\n 3 00:00:00.002135656\n 4 00:00:03.244334234\n dtype: timedelta64[ns]\n >>> s.dt.nanoseconds\n 0 123\n 1 231\n 2 712\n 3 656\n 4 234\n dtype: int64\n "
return self._get_td_field('nanoseconds') | @property
def nanoseconds(self):
"\n Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.\n\n Returns\n -------\n Series\n\n Examples\n --------\n >>> import cudf\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,\n ... 3244334234], dtype='timedelta64[ns]')\n >>> s\n 0 00:00:12.231312123\n 1 00:00:01.231231231\n 2 00:18:43.236768712\n 3 00:00:00.002135656\n 4 00:00:03.244334234\n dtype: timedelta64[ns]\n >>> s.dt.nanoseconds\n 0 123\n 1 231\n 2 712\n 3 656\n 4 234\n dtype: int64\n "
return self._get_td_field('nanoseconds')<|docstring|>Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.
Returns
-------
Series
Examples
--------
>>> import cudf
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656,
... 3244334234], dtype='timedelta64[ns]')
>>> s
0 00:00:12.231312123
1 00:00:01.231231231
2 00:18:43.236768712
3 00:00:00.002135656
4 00:00:03.244334234
dtype: timedelta64[ns]
>>> s.dt.nanoseconds
0 123
1 231
2 712
3 656
4 234
dtype: int64<|endoftext|> |
e98905fc0d1c1133d9ec7b2804df3a253d9a7958312e6e5095e82117fdbc3b3e | @property
def components(self):
"\n Return a Dataframe of the components of the Timedeltas.\n\n Returns\n -------\n DataFrame\n\n Examples\n --------\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656, 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.components\n days hours minutes seconds milliseconds microseconds nanoseconds\n 0 141 13 35 12 123 0 0\n 1 14 6 0 31 231 0 0\n 2 13000 10 12 48 712 0 0\n 3 0 0 35 35 656 0 0\n 4 37 13 12 14 234 0 0\n "
return self.series._column.components(index=self.series._index) | Return a Dataframe of the components of the Timedeltas.
Returns
-------
DataFrame
Examples
--------
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656, 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.components
days hours minutes seconds milliseconds microseconds nanoseconds
0 141 13 35 12 123 0 0
1 14 6 0 31 231 0 0
2 13000 10 12 48 712 0 0
3 0 0 35 35 656 0 0
4 37 13 12 14 234 0 0 | python/cudf/cudf/core/series.py | components | jdye64/cudf | 1 | python | @property
def components(self):
"\n Return a Dataframe of the components of the Timedeltas.\n\n Returns\n -------\n DataFrame\n\n Examples\n --------\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656, 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.components\n days hours minutes seconds milliseconds microseconds nanoseconds\n 0 141 13 35 12 123 0 0\n 1 14 6 0 31 231 0 0\n 2 13000 10 12 48 712 0 0\n 3 0 0 35 35 656 0 0\n 4 37 13 12 14 234 0 0\n "
return self.series._column.components(index=self.series._index) | @property
def components(self):
"\n Return a Dataframe of the components of the Timedeltas.\n\n Returns\n -------\n DataFrame\n\n Examples\n --------\n >>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656, 3244334234], dtype='timedelta64[ms]')\n >>> s\n 0 141 days 13:35:12.123\n 1 14 days 06:00:31.231\n 2 13000 days 10:12:48.712\n 3 0 days 00:35:35.656\n 4 37 days 13:12:14.234\n dtype: timedelta64[ms]\n >>> s.dt.components\n days hours minutes seconds milliseconds microseconds nanoseconds\n 0 141 13 35 12 123 0 0\n 1 14 6 0 31 231 0 0\n 2 13000 10 12 48 712 0 0\n 3 0 0 35 35 656 0 0\n 4 37 13 12 14 234 0 0\n "
return self.series._column.components(index=self.series._index)<|docstring|>Return a Dataframe of the components of the Timedeltas.
Returns
-------
DataFrame
Examples
--------
>>> s = cudf.Series([12231312123, 1231231231, 1123236768712, 2135656, 3244334234], dtype='timedelta64[ms]')
>>> s
0 141 days 13:35:12.123
1 14 days 06:00:31.231
2 13000 days 10:12:48.712
3 0 days 00:35:35.656
4 37 days 13:12:14.234
dtype: timedelta64[ms]
>>> s.dt.components
days hours minutes seconds milliseconds microseconds nanoseconds
0 141 13 35 12 123 0 0
1 14 6 0 31 231 0 0
2 13000 10 12 48 712 0 0
3 0 0 35 35 656 0 0
4 37 13 12 14 234 0 0<|endoftext|> |
14ed9e81db4bc05a4baa4e6ba35719a5710853e990c5136329c81ce6ecfa77be | def get_domain_root_dn(self) -> str:
'Attempt to get root DN via MS specific fields or generic LDAP fields'
info = self._source.connection.server.info
if ('rootDomainNamingContext' in info.other):
return info.other['rootDomainNamingContext'][0]
naming_contexts = info.naming_contexts
naming_contexts.sort(key=len)
return naming_contexts[0] | Attempt to get root DN via MS specific fields or generic LDAP fields | authentik/sources/ldap/password.py | get_domain_root_dn | BeryJu/passbook | 15 | python | def get_domain_root_dn(self) -> str:
info = self._source.connection.server.info
if ('rootDomainNamingContext' in info.other):
return info.other['rootDomainNamingContext'][0]
naming_contexts = info.naming_contexts
naming_contexts.sort(key=len)
return naming_contexts[0] | def get_domain_root_dn(self) -> str:
info = self._source.connection.server.info
if ('rootDomainNamingContext' in info.other):
return info.other['rootDomainNamingContext'][0]
naming_contexts = info.naming_contexts
naming_contexts.sort(key=len)
return naming_contexts[0]<|docstring|>Attempt to get root DN via MS specific fields or generic LDAP fields<|endoftext|> |
d2e8b675e5718e7b3a5062e79c21c464a2afd4e7896af122bf4f6309766ac828 | def check_ad_password_complexity_enabled(self) -> bool:
'Check if DOMAIN_PASSWORD_COMPLEX is enabled'
root_dn = self.get_domain_root_dn()
try:
root_attrs = self._source.connection.extend.standard.paged_search(search_base=root_dn, search_filter='(objectClass=*)', search_scope=ldap3.BASE, attributes=['pwdProperties'])
root_attrs = list(root_attrs)[0]
except (LDAPAttributeError, KeyError, IndexError):
return False
raw_pwd_properties = root_attrs.get('attributes', {}).get('pwdProperties', None)
if (raw_pwd_properties is None):
return False
pwd_properties = PwdProperties(raw_pwd_properties)
if (PwdProperties.DOMAIN_PASSWORD_COMPLEX in pwd_properties):
return True
return False | Check if DOMAIN_PASSWORD_COMPLEX is enabled | authentik/sources/ldap/password.py | check_ad_password_complexity_enabled | BeryJu/passbook | 15 | python | def check_ad_password_complexity_enabled(self) -> bool:
root_dn = self.get_domain_root_dn()
try:
root_attrs = self._source.connection.extend.standard.paged_search(search_base=root_dn, search_filter='(objectClass=*)', search_scope=ldap3.BASE, attributes=['pwdProperties'])
root_attrs = list(root_attrs)[0]
except (LDAPAttributeError, KeyError, IndexError):
return False
raw_pwd_properties = root_attrs.get('attributes', {}).get('pwdProperties', None)
if (raw_pwd_properties is None):
return False
pwd_properties = PwdProperties(raw_pwd_properties)
if (PwdProperties.DOMAIN_PASSWORD_COMPLEX in pwd_properties):
return True
return False | def check_ad_password_complexity_enabled(self) -> bool:
root_dn = self.get_domain_root_dn()
try:
root_attrs = self._source.connection.extend.standard.paged_search(search_base=root_dn, search_filter='(objectClass=*)', search_scope=ldap3.BASE, attributes=['pwdProperties'])
root_attrs = list(root_attrs)[0]
except (LDAPAttributeError, KeyError, IndexError):
return False
raw_pwd_properties = root_attrs.get('attributes', {}).get('pwdProperties', None)
if (raw_pwd_properties is None):
return False
pwd_properties = PwdProperties(raw_pwd_properties)
if (PwdProperties.DOMAIN_PASSWORD_COMPLEX in pwd_properties):
return True
return False<|docstring|>Check if DOMAIN_PASSWORD_COMPLEX is enabled<|endoftext|> |
d96a67cc5e209ff1d1052708b0375750fe746ea15a17244c3b675cca68cd8724 | def change_password(self, user: User, password: str):
"Change user's password"
user_dn = user.attributes.get(LDAP_DISTINGUISHED_NAME, None)
if (not user_dn):
LOGGER.info(f'User has no {LDAP_DISTINGUISHED_NAME} set.')
return
try:
self._source.connection.extend.microsoft.modify_password(user_dn, password)
except LDAPAttributeError:
self._source.connection.extend.standard.modify_password(user_dn, new_password=password) | Change user's password | authentik/sources/ldap/password.py | change_password | BeryJu/passbook | 15 | python | def change_password(self, user: User, password: str):
user_dn = user.attributes.get(LDAP_DISTINGUISHED_NAME, None)
if (not user_dn):
LOGGER.info(f'User has no {LDAP_DISTINGUISHED_NAME} set.')
return
try:
self._source.connection.extend.microsoft.modify_password(user_dn, password)
except LDAPAttributeError:
self._source.connection.extend.standard.modify_password(user_dn, new_password=password) | def change_password(self, user: User, password: str):
user_dn = user.attributes.get(LDAP_DISTINGUISHED_NAME, None)
if (not user_dn):
LOGGER.info(f'User has no {LDAP_DISTINGUISHED_NAME} set.')
return
try:
self._source.connection.extend.microsoft.modify_password(user_dn, password)
except LDAPAttributeError:
self._source.connection.extend.standard.modify_password(user_dn, new_password=password)<|docstring|>Change user's password<|endoftext|> |
70f9711edc0d7cafb2443ab243f5f634db4ed3b70fa41ab2e3018cabcda6d460 | def _ad_check_password_existing(self, password: str, user_dn: str) -> bool:
'Check if a password contains sAMAccount or displayName'
users = list(self._source.connection.extend.standard.paged_search(search_base=user_dn, search_filter=self._source.user_object_filter, search_scope=ldap3.BASE, attributes=['displayName', 'sAMAccountName']))
if (len(users) != 1):
raise AssertionError()
user_attributes = users[0]['attributes']
if (len(user_attributes['sAMAccountName']) >= 3):
if (password.lower() in user_attributes['sAMAccountName'].lower()):
return False
if (len(user_attributes['displayName']) < 1):
return True
for display_name in user_attributes['displayName']:
display_name_tokens = split(RE_DISPLAYNAME_SEPARATORS, display_name)
for token in display_name_tokens:
if (len(token) < 3):
continue
if (token.lower() in password.lower()):
return False
return True | Check if a password contains sAMAccount or displayName | authentik/sources/ldap/password.py | _ad_check_password_existing | BeryJu/passbook | 15 | python | def _ad_check_password_existing(self, password: str, user_dn: str) -> bool:
users = list(self._source.connection.extend.standard.paged_search(search_base=user_dn, search_filter=self._source.user_object_filter, search_scope=ldap3.BASE, attributes=['displayName', 'sAMAccountName']))
if (len(users) != 1):
raise AssertionError()
user_attributes = users[0]['attributes']
if (len(user_attributes['sAMAccountName']) >= 3):
if (password.lower() in user_attributes['sAMAccountName'].lower()):
return False
if (len(user_attributes['displayName']) < 1):
return True
for display_name in user_attributes['displayName']:
display_name_tokens = split(RE_DISPLAYNAME_SEPARATORS, display_name)
for token in display_name_tokens:
if (len(token) < 3):
continue
if (token.lower() in password.lower()):
return False
return True | def _ad_check_password_existing(self, password: str, user_dn: str) -> bool:
users = list(self._source.connection.extend.standard.paged_search(search_base=user_dn, search_filter=self._source.user_object_filter, search_scope=ldap3.BASE, attributes=['displayName', 'sAMAccountName']))
if (len(users) != 1):
raise AssertionError()
user_attributes = users[0]['attributes']
if (len(user_attributes['sAMAccountName']) >= 3):
if (password.lower() in user_attributes['sAMAccountName'].lower()):
return False
if (len(user_attributes['displayName']) < 1):
return True
for display_name in user_attributes['displayName']:
display_name_tokens = split(RE_DISPLAYNAME_SEPARATORS, display_name)
for token in display_name_tokens:
if (len(token) < 3):
continue
if (token.lower() in password.lower()):
return False
return True<|docstring|>Check if a password contains sAMAccount or displayName<|endoftext|> |
a0638fc6f0ecd40b31b82cddcfcee265895af5841ac39a266f3f6749fbdfdb68 | def ad_password_complexity(self, password: str, user: Optional[User]=None) -> bool:
'Check if password matches Active directory password policies\n\n https://docs.microsoft.com/en-us/windows/security/threat-protection/\n security-policy-settings/password-must-meet-complexity-requirements\n '
if user:
if (LDAP_DISTINGUISHED_NAME in user.attributes):
existing_user_check = self._ad_check_password_existing(password, user.attributes.get(LDAP_DISTINGUISHED_NAME))
if (not existing_user_check):
LOGGER.debug('Password failed name check', user=user)
return existing_user_check
matched_categories = PasswordCategories.NONE
required = 3
for letter in password:
if letter.islower():
matched_categories |= PasswordCategories.ALPHA_LOWER
elif letter.isupper():
matched_categories |= PasswordCategories.ALPHA_UPPER
elif ((not letter.isascii()) and letter.isalpha()):
matched_categories |= PasswordCategories.ALPHA_OTHER
elif letter.isnumeric():
matched_categories |= PasswordCategories.NUMERIC
elif (letter in NON_ALPHA):
matched_categories |= PasswordCategories.SYMBOL
if (bin(matched_categories).count('1') < required):
LOGGER.debug("Password didn't match enough categories", has=matched_categories, must=required)
return False
LOGGER.debug('Password matched categories', has=matched_categories, must=required)
return True | Check if password matches Active directory password policies
https://docs.microsoft.com/en-us/windows/security/threat-protection/
security-policy-settings/password-must-meet-complexity-requirements | authentik/sources/ldap/password.py | ad_password_complexity | BeryJu/passbook | 15 | python | def ad_password_complexity(self, password: str, user: Optional[User]=None) -> bool:
'Check if password matches Active directory password policies\n\n https://docs.microsoft.com/en-us/windows/security/threat-protection/\n security-policy-settings/password-must-meet-complexity-requirements\n '
if user:
if (LDAP_DISTINGUISHED_NAME in user.attributes):
existing_user_check = self._ad_check_password_existing(password, user.attributes.get(LDAP_DISTINGUISHED_NAME))
if (not existing_user_check):
LOGGER.debug('Password failed name check', user=user)
return existing_user_check
matched_categories = PasswordCategories.NONE
required = 3
for letter in password:
if letter.islower():
matched_categories |= PasswordCategories.ALPHA_LOWER
elif letter.isupper():
matched_categories |= PasswordCategories.ALPHA_UPPER
elif ((not letter.isascii()) and letter.isalpha()):
matched_categories |= PasswordCategories.ALPHA_OTHER
elif letter.isnumeric():
matched_categories |= PasswordCategories.NUMERIC
elif (letter in NON_ALPHA):
matched_categories |= PasswordCategories.SYMBOL
if (bin(matched_categories).count('1') < required):
LOGGER.debug("Password didn't match enough categories", has=matched_categories, must=required)
return False
LOGGER.debug('Password matched categories', has=matched_categories, must=required)
return True | def ad_password_complexity(self, password: str, user: Optional[User]=None) -> bool:
'Check if password matches Active directory password policies\n\n https://docs.microsoft.com/en-us/windows/security/threat-protection/\n security-policy-settings/password-must-meet-complexity-requirements\n '
if user:
if (LDAP_DISTINGUISHED_NAME in user.attributes):
existing_user_check = self._ad_check_password_existing(password, user.attributes.get(LDAP_DISTINGUISHED_NAME))
if (not existing_user_check):
LOGGER.debug('Password failed name check', user=user)
return existing_user_check
matched_categories = PasswordCategories.NONE
required = 3
for letter in password:
if letter.islower():
matched_categories |= PasswordCategories.ALPHA_LOWER
elif letter.isupper():
matched_categories |= PasswordCategories.ALPHA_UPPER
elif ((not letter.isascii()) and letter.isalpha()):
matched_categories |= PasswordCategories.ALPHA_OTHER
elif letter.isnumeric():
matched_categories |= PasswordCategories.NUMERIC
elif (letter in NON_ALPHA):
matched_categories |= PasswordCategories.SYMBOL
if (bin(matched_categories).count('1') < required):
LOGGER.debug("Password didn't match enough categories", has=matched_categories, must=required)
return False
LOGGER.debug('Password matched categories', has=matched_categories, must=required)
return True<|docstring|>Check if password matches Active directory password policies
https://docs.microsoft.com/en-us/windows/security/threat-protection/
security-policy-settings/password-must-meet-complexity-requirements<|endoftext|> |
39f1eac6f1d48894e0c6b878345a22347c5943e5da61e10d14453948123a590a | def get_space(self):
'\n Returns a pymunk Space with the ball and rods etc.\n and a dict of bodies in the form:\n {\n "ball": ball_body,\n "rods":[\n rod_0_body,\n rod_1_body,\n ...\n rod_n_body\n ],\n "goals": [\n goal_0_body,\n goal_1_body\n ]\n }\n '
def small_rand(maximum):
return (((random.random() * 2) * maximum) - maximum)
space = pymunk.Space()
space.gravity = (0, 0)
ball_body = pymunk.Body(0, 0)
ball_shape = pymunk.Circle(ball_body, self.ball_radius)
ball_shape.density = 1.0
ball_shape.elasticity = 0.8
ball_body.position = (((self.length / 2) + small_rand(0.05)), (0.5 + small_rand(0.05)))
ball_body.velocity = (small_rand(0.05), small_rand(0.05))
space.add(ball_body, ball_shape)
rod_bodies = []
(foo_w, foo_h, _) = self.foosman_size
def create_rect(body, x, y, w, h):
hw = (w / 2)
hh = (h / 2)
return pymunk.Poly(body, [((x - hw), (y - hh)), ((x - hw), (y + hh)), ((x + hw), (y + hh)), ((x + hw), (y - hh))])
for (owner, x, foo_count, foo_dist, max_offset) in self.rods:
rod_body = pymunk.Body(0, 0, pymunk.Body.KINEMATIC)
rod_body.position = (x, 0.5)
space.add(rod_body)
rod_bodies.append(rod_body)
for body_idx in range(foo_count):
delta_y = (foo_dist * (((foo_count - 1) / 2) - body_idx))
foo_shape = create_rect(rod_body, 0, delta_y, foo_w, foo_h)
space.add(foo_shape)
goal0_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
goal0_body.position = (0, 0.5)
goal0_shape = pymunk.Segment(goal0_body, (0, ((- self.goal_width) / 2)), (0, (self.goal_width / 2)), 0.01)
goal1_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
goal1_body.position = (self.length, 0.5)
goal1_shape = pymunk.Segment(goal1_body, (0, ((- self.goal_width) / 2)), (0, (self.goal_width / 2)), 0.01)
space.add(goal0_body, goal0_shape)
space.add(goal1_body, goal1_shape)
side_top_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_top_body.position = ((self.length / 2), 0)
side_top_shape = pymunk.Segment(side_top_body, (((- self.length) / 2), 0), ((self.length / 2), 0), 0.01)
space.add(side_top_body, side_top_shape)
side_bottom_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_bottom_body.position = ((self.length / 2), 1)
side_bottom_shape = pymunk.Segment(side_bottom_body, (((- self.length) / 2), 0), ((self.length / 2), 0), 0.01)
space.add(side_bottom_body, side_bottom_shape)
goal_clearance = ((1 - self.goal_width) / 2)
side_lt_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_lt_body.position = (0, (goal_clearance / 2))
side_lt_shape = pymunk.Segment(side_lt_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_lt_body, side_lt_shape)
side_lb_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_lb_body.position = (0, (1 - (goal_clearance / 2)))
side_lb_shape = pymunk.Segment(side_lb_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_lb_body, side_lb_shape)
side_rt_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_rt_body.position = (self.length, (goal_clearance / 2))
side_rt_shape = pymunk.Segment(side_rt_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_rt_body, side_rt_shape)
side_rb_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_rb_body.position = (self.length, (1 - (goal_clearance / 2)))
side_rb_shape = pymunk.Segment(side_rb_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_rb_body, side_rb_shape)
side_bodies = [goal0_body, goal1_body, side_top_body, side_bottom_body, side_lt_body, side_lb_body, side_rt_body, side_rb_body]
excl_side_bodies = [side_top_body, side_bottom_body, side_lt_body, side_lb_body, side_rt_body, side_rb_body]
for shape in space.shapes:
shape.elasticity = 0.8
side_filter = pymunk.ShapeFilter(1, 1, (2 | 4))
foo_filter = pymunk.ShapeFilter(2, 2, 4)
ball_filter = pymunk.ShapeFilter(4, 4, (1 | 2))
goal_filter = pymunk.ShapeFilter(1, 1, 2)
def apply_filter(bodies, shape_filter):
for body in bodies:
for shape in body.shapes:
shape.filter = shape_filter
apply_filter(side_bodies, side_filter)
apply_filter(rod_bodies, foo_filter)
apply_filter([ball_body], ball_filter)
apply_filter([goal0_body, goal1_body], goal_filter)
for body in space.bodies:
for shape in body.shapes:
shape.friction = 0
return (space, {'ball': ball_body, 'rods': rod_bodies, 'goals': [goal0_body, goal1_body], 'excl_sides': excl_side_bodies}) | Returns a pymunk Space with the ball and rods etc.
and a dict of bodies in the form:
{
"ball": ball_body,
"rods":[
rod_0_body,
rod_1_body,
...
rod_n_body
],
"goals": [
goal_0_body,
goal_1_body
]
} | sim/table.py | get_space | TED-996/pro-evolution-foosball | 0 | python | def get_space(self):
'\n Returns a pymunk Space with the ball and rods etc.\n and a dict of bodies in the form:\n {\n "ball": ball_body,\n "rods":[\n rod_0_body,\n rod_1_body,\n ...\n rod_n_body\n ],\n "goals": [\n goal_0_body,\n goal_1_body\n ]\n }\n '
def small_rand(maximum):
return (((random.random() * 2) * maximum) - maximum)
space = pymunk.Space()
space.gravity = (0, 0)
ball_body = pymunk.Body(0, 0)
ball_shape = pymunk.Circle(ball_body, self.ball_radius)
ball_shape.density = 1.0
ball_shape.elasticity = 0.8
ball_body.position = (((self.length / 2) + small_rand(0.05)), (0.5 + small_rand(0.05)))
ball_body.velocity = (small_rand(0.05), small_rand(0.05))
space.add(ball_body, ball_shape)
rod_bodies = []
(foo_w, foo_h, _) = self.foosman_size
def create_rect(body, x, y, w, h):
hw = (w / 2)
hh = (h / 2)
return pymunk.Poly(body, [((x - hw), (y - hh)), ((x - hw), (y + hh)), ((x + hw), (y + hh)), ((x + hw), (y - hh))])
for (owner, x, foo_count, foo_dist, max_offset) in self.rods:
rod_body = pymunk.Body(0, 0, pymunk.Body.KINEMATIC)
rod_body.position = (x, 0.5)
space.add(rod_body)
rod_bodies.append(rod_body)
for body_idx in range(foo_count):
delta_y = (foo_dist * (((foo_count - 1) / 2) - body_idx))
foo_shape = create_rect(rod_body, 0, delta_y, foo_w, foo_h)
space.add(foo_shape)
goal0_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
goal0_body.position = (0, 0.5)
goal0_shape = pymunk.Segment(goal0_body, (0, ((- self.goal_width) / 2)), (0, (self.goal_width / 2)), 0.01)
goal1_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
goal1_body.position = (self.length, 0.5)
goal1_shape = pymunk.Segment(goal1_body, (0, ((- self.goal_width) / 2)), (0, (self.goal_width / 2)), 0.01)
space.add(goal0_body, goal0_shape)
space.add(goal1_body, goal1_shape)
side_top_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_top_body.position = ((self.length / 2), 0)
side_top_shape = pymunk.Segment(side_top_body, (((- self.length) / 2), 0), ((self.length / 2), 0), 0.01)
space.add(side_top_body, side_top_shape)
side_bottom_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_bottom_body.position = ((self.length / 2), 1)
side_bottom_shape = pymunk.Segment(side_bottom_body, (((- self.length) / 2), 0), ((self.length / 2), 0), 0.01)
space.add(side_bottom_body, side_bottom_shape)
goal_clearance = ((1 - self.goal_width) / 2)
side_lt_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_lt_body.position = (0, (goal_clearance / 2))
side_lt_shape = pymunk.Segment(side_lt_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_lt_body, side_lt_shape)
side_lb_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_lb_body.position = (0, (1 - (goal_clearance / 2)))
side_lb_shape = pymunk.Segment(side_lb_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_lb_body, side_lb_shape)
side_rt_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_rt_body.position = (self.length, (goal_clearance / 2))
side_rt_shape = pymunk.Segment(side_rt_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_rt_body, side_rt_shape)
side_rb_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_rb_body.position = (self.length, (1 - (goal_clearance / 2)))
side_rb_shape = pymunk.Segment(side_rb_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_rb_body, side_rb_shape)
side_bodies = [goal0_body, goal1_body, side_top_body, side_bottom_body, side_lt_body, side_lb_body, side_rt_body, side_rb_body]
excl_side_bodies = [side_top_body, side_bottom_body, side_lt_body, side_lb_body, side_rt_body, side_rb_body]
for shape in space.shapes:
shape.elasticity = 0.8
side_filter = pymunk.ShapeFilter(1, 1, (2 | 4))
foo_filter = pymunk.ShapeFilter(2, 2, 4)
ball_filter = pymunk.ShapeFilter(4, 4, (1 | 2))
goal_filter = pymunk.ShapeFilter(1, 1, 2)
def apply_filter(bodies, shape_filter):
for body in bodies:
for shape in body.shapes:
shape.filter = shape_filter
apply_filter(side_bodies, side_filter)
apply_filter(rod_bodies, foo_filter)
apply_filter([ball_body], ball_filter)
apply_filter([goal0_body, goal1_body], goal_filter)
for body in space.bodies:
for shape in body.shapes:
shape.friction = 0
return (space, {'ball': ball_body, 'rods': rod_bodies, 'goals': [goal0_body, goal1_body], 'excl_sides': excl_side_bodies}) | def get_space(self):
'\n Returns a pymunk Space with the ball and rods etc.\n and a dict of bodies in the form:\n {\n "ball": ball_body,\n "rods":[\n rod_0_body,\n rod_1_body,\n ...\n rod_n_body\n ],\n "goals": [\n goal_0_body,\n goal_1_body\n ]\n }\n '
def small_rand(maximum):
return (((random.random() * 2) * maximum) - maximum)
space = pymunk.Space()
space.gravity = (0, 0)
ball_body = pymunk.Body(0, 0)
ball_shape = pymunk.Circle(ball_body, self.ball_radius)
ball_shape.density = 1.0
ball_shape.elasticity = 0.8
ball_body.position = (((self.length / 2) + small_rand(0.05)), (0.5 + small_rand(0.05)))
ball_body.velocity = (small_rand(0.05), small_rand(0.05))
space.add(ball_body, ball_shape)
rod_bodies = []
(foo_w, foo_h, _) = self.foosman_size
def create_rect(body, x, y, w, h):
hw = (w / 2)
hh = (h / 2)
return pymunk.Poly(body, [((x - hw), (y - hh)), ((x - hw), (y + hh)), ((x + hw), (y + hh)), ((x + hw), (y - hh))])
for (owner, x, foo_count, foo_dist, max_offset) in self.rods:
rod_body = pymunk.Body(0, 0, pymunk.Body.KINEMATIC)
rod_body.position = (x, 0.5)
space.add(rod_body)
rod_bodies.append(rod_body)
for body_idx in range(foo_count):
delta_y = (foo_dist * (((foo_count - 1) / 2) - body_idx))
foo_shape = create_rect(rod_body, 0, delta_y, foo_w, foo_h)
space.add(foo_shape)
goal0_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
goal0_body.position = (0, 0.5)
goal0_shape = pymunk.Segment(goal0_body, (0, ((- self.goal_width) / 2)), (0, (self.goal_width / 2)), 0.01)
goal1_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
goal1_body.position = (self.length, 0.5)
goal1_shape = pymunk.Segment(goal1_body, (0, ((- self.goal_width) / 2)), (0, (self.goal_width / 2)), 0.01)
space.add(goal0_body, goal0_shape)
space.add(goal1_body, goal1_shape)
side_top_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_top_body.position = ((self.length / 2), 0)
side_top_shape = pymunk.Segment(side_top_body, (((- self.length) / 2), 0), ((self.length / 2), 0), 0.01)
space.add(side_top_body, side_top_shape)
side_bottom_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_bottom_body.position = ((self.length / 2), 1)
side_bottom_shape = pymunk.Segment(side_bottom_body, (((- self.length) / 2), 0), ((self.length / 2), 0), 0.01)
space.add(side_bottom_body, side_bottom_shape)
goal_clearance = ((1 - self.goal_width) / 2)
side_lt_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_lt_body.position = (0, (goal_clearance / 2))
side_lt_shape = pymunk.Segment(side_lt_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_lt_body, side_lt_shape)
side_lb_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_lb_body.position = (0, (1 - (goal_clearance / 2)))
side_lb_shape = pymunk.Segment(side_lb_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_lb_body, side_lb_shape)
side_rt_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_rt_body.position = (self.length, (goal_clearance / 2))
side_rt_shape = pymunk.Segment(side_rt_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_rt_body, side_rt_shape)
side_rb_body = pymunk.Body(0, 0, pymunk.Body.STATIC)
side_rb_body.position = (self.length, (1 - (goal_clearance / 2)))
side_rb_shape = pymunk.Segment(side_rb_body, (0, ((- goal_clearance) / 2)), (0, (goal_clearance / 2)), 0.01)
space.add(side_rb_body, side_rb_shape)
side_bodies = [goal0_body, goal1_body, side_top_body, side_bottom_body, side_lt_body, side_lb_body, side_rt_body, side_rb_body]
excl_side_bodies = [side_top_body, side_bottom_body, side_lt_body, side_lb_body, side_rt_body, side_rb_body]
for shape in space.shapes:
shape.elasticity = 0.8
side_filter = pymunk.ShapeFilter(1, 1, (2 | 4))
foo_filter = pymunk.ShapeFilter(2, 2, 4)
ball_filter = pymunk.ShapeFilter(4, 4, (1 | 2))
goal_filter = pymunk.ShapeFilter(1, 1, 2)
def apply_filter(bodies, shape_filter):
for body in bodies:
for shape in body.shapes:
shape.filter = shape_filter
apply_filter(side_bodies, side_filter)
apply_filter(rod_bodies, foo_filter)
apply_filter([ball_body], ball_filter)
apply_filter([goal0_body, goal1_body], goal_filter)
for body in space.bodies:
for shape in body.shapes:
shape.friction = 0
return (space, {'ball': ball_body, 'rods': rod_bodies, 'goals': [goal0_body, goal1_body], 'excl_sides': excl_side_bodies})<|docstring|>Returns a pymunk Space with the ball and rods etc.
and a dict of bodies in the form:
{
"ball": ball_body,
"rods":[
rod_0_body,
rod_1_body,
...
rod_n_body
],
"goals": [
goal_0_body,
goal_1_body
]
}<|endoftext|> |
77bce3300000249df6ce4335d69089b5b14afd79374e888ce19d862ba18eac20 | def visualizeTransform(transform, name):
' Input:\n transform - geometry_msgs.Transform()\n name - string, name of transform\n '
rospy.wait_for_service('/tf2/visualize_transform')
tf2Service = rospy.ServiceProxy('/tf2/visualize_transform', tf2VisualizeTransformSrv)
_ = tf2Service(transform, String(name)) | Input:
transform - geometry_msgs.Transform()
name - string, name of transform | rob9/scripts/rob9Utils/transformations.py | visualizeTransform | daniellehot/ROB10 | 0 | python | def visualizeTransform(transform, name):
' Input:\n transform - geometry_msgs.Transform()\n name - string, name of transform\n '
rospy.wait_for_service('/tf2/visualize_transform')
tf2Service = rospy.ServiceProxy('/tf2/visualize_transform', tf2VisualizeTransformSrv)
_ = tf2Service(transform, String(name)) | def visualizeTransform(transform, name):
' Input:\n transform - geometry_msgs.Transform()\n name - string, name of transform\n '
rospy.wait_for_service('/tf2/visualize_transform')
tf2Service = rospy.ServiceProxy('/tf2/visualize_transform', tf2VisualizeTransformSrv)
_ = tf2Service(transform, String(name))<|docstring|>Input:
transform - geometry_msgs.Transform()
name - string, name of transform<|endoftext|> |
0e714ef650f0086cf28f0345068babe1bf683f054ef6bd9f1c1f8eafaf512f9c | def transformToFrame(pose, newFrame, currentFrame='ptu_camera_color_optical_frame'):
' input: pose - geometry_msgs.PoseStamped()\n numpy array (x, y, z)\n numpy array (x, y, z, qx, qy, qz, qw)\n newFrame - desired frame for pose to be transformed into.\n output: transformed_pose_msg - pose in newFrame '
if isinstance(pose, (np.ndarray, np.generic)):
npArr = pose
pose = PoseStamped()
pose.pose.position.x = npArr[0]
pose.pose.position.y = npArr[1]
pose.pose.position.z = npArr[2]
if (npArr.shape[0] < 4):
pose.pose.orientation.w = 1
pose.pose.orientation.x = 0
pose.pose.orientation.y = 0
pose.pose.orientation.z = 0
else:
pose.pose.orientation.w = npArr[6]
pose.pose.orientation.x = npArr[3]
pose.pose.orientation.y = npArr[4]
pose.pose.orientation.z = npArr[5]
pose.header.frame_id = currentFrame
pose.header.stamp = rospy.Time.now()
rospy.wait_for_service('/tf2/transformPoseStamped')
tf2Service = rospy.ServiceProxy('/tf2/transformPoseStamped', tf2TransformPoseStampedSrv)
response = tf2Service(pose, String(newFrame)).data
return response | input: pose - geometry_msgs.PoseStamped()
numpy array (x, y, z)
numpy array (x, y, z, qx, qy, qz, qw)
newFrame - desired frame for pose to be transformed into.
output: transformed_pose_msg - pose in newFrame | rob9/scripts/rob9Utils/transformations.py | transformToFrame | daniellehot/ROB10 | 0 | python | def transformToFrame(pose, newFrame, currentFrame='ptu_camera_color_optical_frame'):
' input: pose - geometry_msgs.PoseStamped()\n numpy array (x, y, z)\n numpy array (x, y, z, qx, qy, qz, qw)\n newFrame - desired frame for pose to be transformed into.\n output: transformed_pose_msg - pose in newFrame '
if isinstance(pose, (np.ndarray, np.generic)):
npArr = pose
pose = PoseStamped()
pose.pose.position.x = npArr[0]
pose.pose.position.y = npArr[1]
pose.pose.position.z = npArr[2]
if (npArr.shape[0] < 4):
pose.pose.orientation.w = 1
pose.pose.orientation.x = 0
pose.pose.orientation.y = 0
pose.pose.orientation.z = 0
else:
pose.pose.orientation.w = npArr[6]
pose.pose.orientation.x = npArr[3]
pose.pose.orientation.y = npArr[4]
pose.pose.orientation.z = npArr[5]
pose.header.frame_id = currentFrame
pose.header.stamp = rospy.Time.now()
rospy.wait_for_service('/tf2/transformPoseStamped')
tf2Service = rospy.ServiceProxy('/tf2/transformPoseStamped', tf2TransformPoseStampedSrv)
response = tf2Service(pose, String(newFrame)).data
return response | def transformToFrame(pose, newFrame, currentFrame='ptu_camera_color_optical_frame'):
' input: pose - geometry_msgs.PoseStamped()\n numpy array (x, y, z)\n numpy array (x, y, z, qx, qy, qz, qw)\n newFrame - desired frame for pose to be transformed into.\n output: transformed_pose_msg - pose in newFrame '
if isinstance(pose, (np.ndarray, np.generic)):
npArr = pose
pose = PoseStamped()
pose.pose.position.x = npArr[0]
pose.pose.position.y = npArr[1]
pose.pose.position.z = npArr[2]
if (npArr.shape[0] < 4):
pose.pose.orientation.w = 1
pose.pose.orientation.x = 0
pose.pose.orientation.y = 0
pose.pose.orientation.z = 0
else:
pose.pose.orientation.w = npArr[6]
pose.pose.orientation.x = npArr[3]
pose.pose.orientation.y = npArr[4]
pose.pose.orientation.z = npArr[5]
pose.header.frame_id = currentFrame
pose.header.stamp = rospy.Time.now()
rospy.wait_for_service('/tf2/transformPoseStamped')
tf2Service = rospy.ServiceProxy('/tf2/transformPoseStamped', tf2TransformPoseStampedSrv)
response = tf2Service(pose, String(newFrame)).data
return response<|docstring|>input: pose - geometry_msgs.PoseStamped()
numpy array (x, y, z)
numpy array (x, y, z, qx, qy, qz, qw)
newFrame - desired frame for pose to be transformed into.
output: transformed_pose_msg - pose in newFrame<|endoftext|> |
9f722b717381aaf94d66bc7994eb65a271d6148ce58b23d85ec11acecaca6c64 | def transformToFramePath(path, newFrame):
' input: pose - nav_msgs.Path()\n newFrame - desired frame for pose to be transformed into.\n output: transformed_path_msg - path in newFrame '
pose.header.stamp = rospy.Time.now()
rospy.wait_for_service('/tf2/transformPath')
tf2Service = rospy.ServiceProxy('/tf2/transformPath', tf2TransformPathSrv)
response = tf2Service(path, String(newFrame))
return response | input: pose - nav_msgs.Path()
newFrame - desired frame for pose to be transformed into.
output: transformed_path_msg - path in newFrame | rob9/scripts/rob9Utils/transformations.py | transformToFramePath | daniellehot/ROB10 | 0 | python | def transformToFramePath(path, newFrame):
' input: pose - nav_msgs.Path()\n newFrame - desired frame for pose to be transformed into.\n output: transformed_path_msg - path in newFrame '
pose.header.stamp = rospy.Time.now()
rospy.wait_for_service('/tf2/transformPath')
tf2Service = rospy.ServiceProxy('/tf2/transformPath', tf2TransformPathSrv)
response = tf2Service(path, String(newFrame))
return response | def transformToFramePath(path, newFrame):
' input: pose - nav_msgs.Path()\n newFrame - desired frame for pose to be transformed into.\n output: transformed_path_msg - path in newFrame '
pose.header.stamp = rospy.Time.now()
rospy.wait_for_service('/tf2/transformPath')
tf2Service = rospy.ServiceProxy('/tf2/transformPath', tf2TransformPathSrv)
response = tf2Service(path, String(newFrame))
return response<|docstring|>input: pose - nav_msgs.Path()
newFrame - desired frame for pose to be transformed into.
output: transformed_path_msg - path in newFrame<|endoftext|> |
399e17a8800c442c8da1285e51f7c46eaf9a7bcecd16d47f9487f80655441d9b | def poseToTransform(pose):
' Input:\n pose - array [x, y, z, qx, qy, qz, qw]\n\n Output:\n transform - geometry_msgs.Transform()\n '
transform = Transform()
transform.translation.x = pose[0]
transform.translation.y = pose[1]
transform.translation.z = pose[2]
transform.rotation.x = pose[3]
transform.rotation.y = pose[4]
transform.rotation.z = pose[5]
transform.rotation.w = pose[6]
return transform | Input:
pose - array [x, y, z, qx, qy, qz, qw]
Output:
transform - geometry_msgs.Transform() | rob9/scripts/rob9Utils/transformations.py | poseToTransform | daniellehot/ROB10 | 0 | python | def poseToTransform(pose):
' Input:\n pose - array [x, y, z, qx, qy, qz, qw]\n\n Output:\n transform - geometry_msgs.Transform()\n '
transform = Transform()
transform.translation.x = pose[0]
transform.translation.y = pose[1]
transform.translation.z = pose[2]
transform.rotation.x = pose[3]
transform.rotation.y = pose[4]
transform.rotation.z = pose[5]
transform.rotation.w = pose[6]
return transform | def poseToTransform(pose):
' Input:\n pose - array [x, y, z, qx, qy, qz, qw]\n\n Output:\n transform - geometry_msgs.Transform()\n '
transform = Transform()
transform.translation.x = pose[0]
transform.translation.y = pose[1]
transform.translation.z = pose[2]
transform.rotation.x = pose[3]
transform.rotation.y = pose[4]
transform.rotation.z = pose[5]
transform.rotation.w = pose[6]
return transform<|docstring|>Input:
pose - array [x, y, z, qx, qy, qz, qw]
Output:
transform - geometry_msgs.Transform()<|endoftext|> |
7aefc300c2e1f9565454d08db90f3caf56fda1ef06d85b1ebd8570ce891181eb | def poseMsgToTransformMsg(pose):
' Input:\n pose - geometry_msgs.Pose()\n\n Output:\n transform - geometry_msgs.Transform()\n '
transform = Transform()
transform.translation.x = pose.position.x
transform.translation.y = pose.position.y
transform.translation.z = pose.position.z
transform.rotation.x = pose.orientation.x
transform.rotation.y = pose.orientation.y
transform.rotation.z = pose.orientation.z
transform.rotation.w = pose.orientation.w
return transform | Input:
pose - geometry_msgs.Pose()
Output:
transform - geometry_msgs.Transform() | rob9/scripts/rob9Utils/transformations.py | poseMsgToTransformMsg | daniellehot/ROB10 | 0 | python | def poseMsgToTransformMsg(pose):
' Input:\n pose - geometry_msgs.Pose()\n\n Output:\n transform - geometry_msgs.Transform()\n '
transform = Transform()
transform.translation.x = pose.position.x
transform.translation.y = pose.position.y
transform.translation.z = pose.position.z
transform.rotation.x = pose.orientation.x
transform.rotation.y = pose.orientation.y
transform.rotation.z = pose.orientation.z
transform.rotation.w = pose.orientation.w
return transform | def poseMsgToTransformMsg(pose):
' Input:\n pose - geometry_msgs.Pose()\n\n Output:\n transform - geometry_msgs.Transform()\n '
transform = Transform()
transform.translation.x = pose.position.x
transform.translation.y = pose.position.y
transform.translation.z = pose.position.z
transform.rotation.x = pose.orientation.x
transform.rotation.y = pose.orientation.y
transform.rotation.z = pose.orientation.z
transform.rotation.w = pose.orientation.w
return transform<|docstring|>Input:
pose - geometry_msgs.Pose()
Output:
transform - geometry_msgs.Transform()<|endoftext|> |
426e1132407f24abb02eb1115183804c49364580c421da5a4c8b261d859ce113 | def getTransform(source_frame, target_frame):
' input:\n source_frame - string\n target_frame - string\n\n output:\n T - 4x4 homogeneous transformation, np.array()\n transl - x, y, z translation, np.array(), shape (3)\n rot - 3x3 rotation matrix, np.array(), shape (3, 3)\n '
rospy.wait_for_service('/tf2/get_transform')
tf2Service = rospy.ServiceProxy('/tf2/get_transform', tf2GetTransformSrv)
source_msg = String()
source_msg.data = source_frame
target_msg = String()
target_msg.data = target_frame
response = tf2Service(source_msg, target_msg)
transl = np.zeros((3, 1))
transl[0] = response.transform.translation.x
transl[1] = response.transform.translation.y
transl[2] = response.transform.translation.z
msg_quat = response.transform.rotation
quat = [msg_quat.x, msg_quat.y, msg_quat.z, msg_quat.w]
rot = quatToRot(quat)
T = np.identity(4)
T[(0:3, 0:3)] = rot
T[(0, 3)] = response.transform.translation.x
T[(1, 3)] = response.transform.translation.y
T[(2, 3)] = response.transform.translation.z
return (T, transl.flatten(), rot) | input:
source_frame - string
target_frame - string
output:
T - 4x4 homogeneous transformation, np.array()
transl - x, y, z translation, np.array(), shape (3)
rot - 3x3 rotation matrix, np.array(), shape (3, 3) | rob9/scripts/rob9Utils/transformations.py | getTransform | daniellehot/ROB10 | 0 | python | def getTransform(source_frame, target_frame):
' input:\n source_frame - string\n target_frame - string\n\n output:\n T - 4x4 homogeneous transformation, np.array()\n transl - x, y, z translation, np.array(), shape (3)\n rot - 3x3 rotation matrix, np.array(), shape (3, 3)\n '
rospy.wait_for_service('/tf2/get_transform')
tf2Service = rospy.ServiceProxy('/tf2/get_transform', tf2GetTransformSrv)
source_msg = String()
source_msg.data = source_frame
target_msg = String()
target_msg.data = target_frame
response = tf2Service(source_msg, target_msg)
transl = np.zeros((3, 1))
transl[0] = response.transform.translation.x
transl[1] = response.transform.translation.y
transl[2] = response.transform.translation.z
msg_quat = response.transform.rotation
quat = [msg_quat.x, msg_quat.y, msg_quat.z, msg_quat.w]
rot = quatToRot(quat)
T = np.identity(4)
T[(0:3, 0:3)] = rot
T[(0, 3)] = response.transform.translation.x
T[(1, 3)] = response.transform.translation.y
T[(2, 3)] = response.transform.translation.z
return (T, transl.flatten(), rot) | def getTransform(source_frame, target_frame):
' input:\n source_frame - string\n target_frame - string\n\n output:\n T - 4x4 homogeneous transformation, np.array()\n transl - x, y, z translation, np.array(), shape (3)\n rot - 3x3 rotation matrix, np.array(), shape (3, 3)\n '
rospy.wait_for_service('/tf2/get_transform')
tf2Service = rospy.ServiceProxy('/tf2/get_transform', tf2GetTransformSrv)
source_msg = String()
source_msg.data = source_frame
target_msg = String()
target_msg.data = target_frame
response = tf2Service(source_msg, target_msg)
transl = np.zeros((3, 1))
transl[0] = response.transform.translation.x
transl[1] = response.transform.translation.y
transl[2] = response.transform.translation.z
msg_quat = response.transform.rotation
quat = [msg_quat.x, msg_quat.y, msg_quat.z, msg_quat.w]
rot = quatToRot(quat)
T = np.identity(4)
T[(0:3, 0:3)] = rot
T[(0, 3)] = response.transform.translation.x
T[(1, 3)] = response.transform.translation.y
T[(2, 3)] = response.transform.translation.z
return (T, transl.flatten(), rot)<|docstring|>input:
source_frame - string
target_frame - string
output:
T - 4x4 homogeneous transformation, np.array()
transl - x, y, z translation, np.array(), shape (3)
rot - 3x3 rotation matrix, np.array(), shape (3, 3)<|endoftext|> |
a8b6e06ba1db1480621afea91e6926193f16cb4b4e87499d58a4fc861d8d4bea | def quatToRot(q):
' input: - q, array [x, y, z, w]\n output: - R, matrix 3x3 rotation matrix\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x, y, z, w) = q
quaternion = [w, x, y, z]
q = np.array(quaternion, dtype=np.float64, copy=True)
n = np.dot(q, q)
if (n < (np.finfo(float).eps * 4.0)):
return np.identity(3).flatten()
q *= math.sqrt((2.0 / n))
q = np.outer(q, q)
R = np.array([[((1.0 - q[(2, 2)]) - q[(3, 3)]), (q[(1, 2)] - q[(3, 0)]), (q[(1, 3)] + q[(2, 0)]), 0.0], [(q[(1, 2)] + q[(3, 0)]), ((1.0 - q[(1, 1)]) - q[(3, 3)]), (q[(2, 3)] - q[(1, 0)]), 0.0], [(q[(1, 3)] - q[(2, 0)]), (q[(2, 3)] + q[(1, 0)]), ((1.0 - q[(1, 1)]) - q[(2, 2)]), 0.0], [0.0, 0.0, 0.0, 1.0]])
return R[(:3, :3)] | input: - q, array [x, y, z, w]
output: - R, matrix 3x3 rotation matrix
https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py | rob9/scripts/rob9Utils/transformations.py | quatToRot | daniellehot/ROB10 | 0 | python | def quatToRot(q):
' input: - q, array [x, y, z, w]\n output: - R, matrix 3x3 rotation matrix\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x, y, z, w) = q
quaternion = [w, x, y, z]
q = np.array(quaternion, dtype=np.float64, copy=True)
n = np.dot(q, q)
if (n < (np.finfo(float).eps * 4.0)):
return np.identity(3).flatten()
q *= math.sqrt((2.0 / n))
q = np.outer(q, q)
R = np.array([[((1.0 - q[(2, 2)]) - q[(3, 3)]), (q[(1, 2)] - q[(3, 0)]), (q[(1, 3)] + q[(2, 0)]), 0.0], [(q[(1, 2)] + q[(3, 0)]), ((1.0 - q[(1, 1)]) - q[(3, 3)]), (q[(2, 3)] - q[(1, 0)]), 0.0], [(q[(1, 3)] - q[(2, 0)]), (q[(2, 3)] + q[(1, 0)]), ((1.0 - q[(1, 1)]) - q[(2, 2)]), 0.0], [0.0, 0.0, 0.0, 1.0]])
return R[(:3, :3)] | def quatToRot(q):
' input: - q, array [x, y, z, w]\n output: - R, matrix 3x3 rotation matrix\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x, y, z, w) = q
quaternion = [w, x, y, z]
q = np.array(quaternion, dtype=np.float64, copy=True)
n = np.dot(q, q)
if (n < (np.finfo(float).eps * 4.0)):
return np.identity(3).flatten()
q *= math.sqrt((2.0 / n))
q = np.outer(q, q)
R = np.array([[((1.0 - q[(2, 2)]) - q[(3, 3)]), (q[(1, 2)] - q[(3, 0)]), (q[(1, 3)] + q[(2, 0)]), 0.0], [(q[(1, 2)] + q[(3, 0)]), ((1.0 - q[(1, 1)]) - q[(3, 3)]), (q[(2, 3)] - q[(1, 0)]), 0.0], [(q[(1, 3)] - q[(2, 0)]), (q[(2, 3)] + q[(1, 0)]), ((1.0 - q[(1, 1)]) - q[(2, 2)]), 0.0], [0.0, 0.0, 0.0, 1.0]])
return R[(:3, :3)]<|docstring|>input: - q, array [x, y, z, w]
output: - R, matrix 3x3 rotation matrix
https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py<|endoftext|> |
07b1d1cfdc5c0917aa2ce23014b7c49d4e602162812166bed1077e00238f7d6c | def cartesianToSpherical(x, y, z):
' input: cartesian coordinates\n output: 3 spherical coordinates '
polar = math.atan2(math.sqrt(((x ** 2) + (y ** 2))), z)
azimuth = math.atan2(y, x)
r = math.sqrt((((x ** 2) + (y ** 2)) + (z ** 2)))
return (r, polar, azimuth) | input: cartesian coordinates
output: 3 spherical coordinates | rob9/scripts/rob9Utils/transformations.py | cartesianToSpherical | daniellehot/ROB10 | 0 | python | def cartesianToSpherical(x, y, z):
' input: cartesian coordinates\n output: 3 spherical coordinates '
polar = math.atan2(math.sqrt(((x ** 2) + (y ** 2))), z)
azimuth = math.atan2(y, x)
r = math.sqrt((((x ** 2) + (y ** 2)) + (z ** 2)))
return (r, polar, azimuth) | def cartesianToSpherical(x, y, z):
' input: cartesian coordinates\n output: 3 spherical coordinates '
polar = math.atan2(math.sqrt(((x ** 2) + (y ** 2))), z)
azimuth = math.atan2(y, x)
r = math.sqrt((((x ** 2) + (y ** 2)) + (z ** 2)))
return (r, polar, azimuth)<|docstring|>input: cartesian coordinates
output: 3 spherical coordinates<|endoftext|> |
c203b526e54c9e31a44c7490885041a5d4ce9c78f3d9aa7fed5e7d1674e33ba6 | def quaternionMultiply(q1, q2):
' input: - q1, array or list, format xyzw\n - q2, array or list, format xyzw\n output: - q, array or list, format xyzw\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x2, y2, z2, w2) = q1
(x1, y1, z1, w1) = q2
q = [(((((- x2) * x1) - (y2 * y1)) - (z2 * z1)) + (w2 * w1)), ((((x2 * w1) + (y2 * z1)) - (z2 * y1)) + (w2 * x1)), (((((- x2) * z1) + (y2 * w1)) + (z2 * x1)) + (w2 * y1)), ((((x2 * y1) - (y2 * x1)) + (z2 * w1)) + (w2 * z1))]
(x, y, z, w) = (q[1], q[2], q[3], q[0])
return [x, y, z, w] | input: - q1, array or list, format xyzw
- q2, array or list, format xyzw
output: - q, array or list, format xyzw
https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py | rob9/scripts/rob9Utils/transformations.py | quaternionMultiply | daniellehot/ROB10 | 0 | python | def quaternionMultiply(q1, q2):
' input: - q1, array or list, format xyzw\n - q2, array or list, format xyzw\n output: - q, array or list, format xyzw\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x2, y2, z2, w2) = q1
(x1, y1, z1, w1) = q2
q = [(((((- x2) * x1) - (y2 * y1)) - (z2 * z1)) + (w2 * w1)), ((((x2 * w1) + (y2 * z1)) - (z2 * y1)) + (w2 * x1)), (((((- x2) * z1) + (y2 * w1)) + (z2 * x1)) + (w2 * y1)), ((((x2 * y1) - (y2 * x1)) + (z2 * w1)) + (w2 * z1))]
(x, y, z, w) = (q[1], q[2], q[3], q[0])
return [x, y, z, w] | def quaternionMultiply(q1, q2):
' input: - q1, array or list, format xyzw\n - q2, array or list, format xyzw\n output: - q, array or list, format xyzw\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x2, y2, z2, w2) = q1
(x1, y1, z1, w1) = q2
q = [(((((- x2) * x1) - (y2 * y1)) - (z2 * z1)) + (w2 * w1)), ((((x2 * w1) + (y2 * z1)) - (z2 * y1)) + (w2 * x1)), (((((- x2) * z1) + (y2 * w1)) + (z2 * x1)) + (w2 * y1)), ((((x2 * y1) - (y2 * x1)) + (z2 * w1)) + (w2 * z1))]
(x, y, z, w) = (q[1], q[2], q[3], q[0])
return [x, y, z, w]<|docstring|>input: - q1, array or list, format xyzw
- q2, array or list, format xyzw
output: - q, array or list, format xyzw
https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py<|endoftext|> |
fa80b18347df903adf35a7c599b7fe0cd558db8146c80829e8756d47c49d2956 | def quaternionConjugate(q):
' input: - q, array or list, format xyzw\n output: - qc, array or list, format xyzw\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x, y, z, w) = q
qc = [(- x), (- y), (- z), w]
return qc | input: - q, array or list, format xyzw
output: - qc, array or list, format xyzw
https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py | rob9/scripts/rob9Utils/transformations.py | quaternionConjugate | daniellehot/ROB10 | 0 | python | def quaternionConjugate(q):
' input: - q, array or list, format xyzw\n output: - qc, array or list, format xyzw\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x, y, z, w) = q
qc = [(- x), (- y), (- z), w]
return qc | def quaternionConjugate(q):
' input: - q, array or list, format xyzw\n output: - qc, array or list, format xyzw\n https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py\n '
(x, y, z, w) = q
qc = [(- x), (- y), (- z), w]
return qc<|docstring|>input: - q, array or list, format xyzw
output: - qc, array or list, format xyzw
https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py<|endoftext|> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.