Skip to content

gh-372 : Fixing Series.astype() #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0469f47
adding overloads to astype
ramvikrams Jan 25, 2023
f0317de
Created the table for astype
ramvikrams Jan 26, 2023
3a75501
Update table.rst
ramvikrams Jan 26, 2023
c5a2073
Updated the table and added numpy dtypes
ramvikrams Jan 26, 2023
67fa6da
Update table.rst
ramvikrams Jan 26, 2023
0cc665b
updated np.datetime64
ramvikrams Feb 7, 2023
96903fb
Update table.rst
ramvikrams Feb 7, 2023
e61394d
added types in Timedelta
ramvikrams Feb 7, 2023
4fa513a
removed not required args in Dtype
ramvikrams Feb 7, 2023
848753e
removed np.timedelta64 in Timedelta
ramvikrams Feb 7, 2023
d8f8616
Removed timedelta64
ramvikrams Feb 7, 2023
814df47
expanding series astype
ramvikrams Feb 16, 2023
ae6cfb1
Merge branch 't90' of https://github.com/ramvikrams/pandas-stubs into…
ramvikrams Feb 16, 2023
dea0042
Added type in args in dtype
ramvikrams Feb 17, 2023
0e84068
corrected the args
ramvikrams Feb 17, 2023
a865484
adding a overload for 'category' and normal changes
ramvikrams Feb 19, 2023
17ce1aa
added tests
ramvikrams Feb 20, 2023
7a84f40
removed unused args
ramvikrams Feb 20, 2023
a139821
Merge branch 'pandas-dev:main' into t90
ramvikrams Feb 21, 2023
7fb2c3f
corrected tests
ramvikrams Feb 23, 2023
3406aa0
Delete table.rst
ramvikrams Feb 23, 2023
5508f4a
added the bool overload to top and done the required test changes
ramvikrams Feb 23, 2023
fefdd83
added type_checker
ramvikrams Feb 24, 2023
6918643
added types for check and did requested changes
ramvikrams Feb 24, 2023
a80df88
updated the check types
ramvikrams Feb 24, 2023
f43a5e8
added astype in dataframe and other changes
ramvikrams Feb 25, 2023
3b86a87
Update test_series.py
ramvikrams Feb 25, 2023
f6a8949
Update test_series.py
ramvikrams Feb 25, 2023
3259170
added dict test for astype in datatest_frame and tests for ExtensionD…
ramvikrams Feb 25, 2023
4090d31
commented out the decimal tests
ramvikrams Feb 25, 2023
29540d3
Update test_series.py
ramvikrams Feb 25, 2023
f46cc52
updated dtype args in astype
ramvikrams Feb 25, 2023
b9f5adb
added any to list of args for astype
ramvikrams Feb 25, 2023
7879ede
changed dtype args
ramvikrams Feb 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from core.api import(
Int8Dtype as Int8Dtype,
Int16Dtype as Int16Dtype,
Int32Dtype as Int32Dtype,
Int64Dtype as Int64Dtype,
)
from collections.abc import (
Callable,
Hashable,
Expand Down Expand Up @@ -1025,12 +1031,26 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
axis: SeriesAxisType | None = ...,
ignore_index: _bool = ...,
) -> Series[S1]: ...
#def astype(
# self,
# dtype: S1 | _str | type[Scalar],
# copy: _bool = ...,
#errors: IgnoreRaise = ...,
#) -> Series: ...
@overload
def astype(
self,
dtype: S1 | _str | type[Scalar],
dtype: S1, _str,
copy: _bool = ...,
errors: IgnoreRaise = ...,
) -> Series: ...
errors: IgnoreRaise = ...
) -> Series[str]: ...
@overload
def astype(
self,
dtype: S1, Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype,
copy: _bool = ...,
errors: IgnoreRaise = ...
) -> Series[int]: ...
def copy(self, deep: _bool = ...) -> Series[S1]: ...
def infer_objects(self) -> Series[S1]: ...
def convert_dtypes(
Expand Down
49 changes: 49 additions & 0 deletions table.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

Table for astype


+-------------------+-------------------------+
| S1 | Dtype |
+===================+=========================+
| int | pd.Int8Dtype, |
| | pd.Int16Dtype, |
| | pd.Int32Dtype, |
| | pd.Int54Dtype, |
| | "int",int,np.int8, |
| | np.int16,np.int32, |
| | np.int64,np.uint8 |
| | np.uint16,np.uint32 |
| | np.uint64,np.intp |
| | np.uintp,np.integer |
+-------------------+-------------------------+
| str | StringDtype,str,"str" |
+-------------------+-------------------------+
| bytes | np.byte,np.ubyte,bytes |
| | "bytes" |
+-------------------+-------------------------+
| float | pd.Float32Dtype, |
| | pd.Float64Dtype, |
| | float,"float",np.float16|
| | np.float32,np.float64 |
| | np.float96,np.float128 |
| | np.floating |
+-------------------+-------------------------+
| complex | "complex",np.complex64, |
| | np.complex128, |
| | np.complex192, |
| | np.complex256, |
| | complex |
+-------------------+-------------------------+
| bool | pd.BooleanDtype, bool |
| | np.bool_ |
| | "bool" |
+-------------------+-------------------------+
| Timedelta | np.timedelta64, |
| | Timedelta, |
| | "timedelta64[ns]" |
| | |
+-------------------+-------------------------+
| Timestamp | Timestamp |
| | "datetime64[ns]" |
+-------------------+-------------------------+