-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
ENH: Add dtype argument to read_sql_query (GH10285) #37546
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
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bcbe5ea
ENH: Add dtype argument to read_sql_query
avinashpancham 9c4f034
Update sql unit tests
avinashpancham 620c0ab
Update type hinting and update doc
avinashpancham bcef60e
Add test
avinashpancham 5c88e5c
Merge remote-tracking branch 'upstream/master' into GH10285
avinashpancham 24308c4
Merge remote-tracking branch 'upstream/master' into GH10285
avinashpancham d6cc4b7
Merge remote-tracking branch 'upstream/master' into GH10285
avinashpancham 5de64f2
Address comments
avinashpancham e9be344
Merge remote-tracking branch 'upstream/master' into GH10285
avinashpancham d7d4439
Merge remote-tracking branch 'upstream/master' into GH10285
avinashpancham dbf1f5f
Merge remote-tracking branch 'upstream/master' into GH10285
avinashpancham a4e7cdf
Address comments
avinashpancham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
Address comments
- Loading branch information
commit a4e7cdf4e90255ee3d20611f19e045db8f84ea2a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,11 +94,11 @@ | |
Axes = Collection | ||
|
||
# dtypes | ||
|
||
Dtype = Union[ | ||
"ExtensionDtype", str, np.dtype, Type[Union[str, float, int, complex, bool, object]] | ||
] | ||
DtypeArg = Optional[Union[Dtype, Dict[Label, Dtype]]] | ||
# DtypeArg specifies all allowable dtypes in a functions its dtype argument | ||
DtypeArg = Union[Dtype, Dict[Label, Dtype]] | ||
DtypeObj = Union[np.dtype, "ExtensionDtype"] | ||
|
||
# For functions like rename that convert one label to another | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved the dtype block since |
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,7 @@ def _wrap_result( | |
index_col=None, | ||
coerce_float: bool = True, | ||
parse_dates=None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
): | ||
"""Wrap result set of query in a DataFrame.""" | ||
frame = DataFrame.from_records(data, columns=columns, coerce_float=coerce_float) | ||
|
@@ -313,7 +313,7 @@ def read_sql_query( | |
params=None, | ||
parse_dates=None, | ||
chunksize: None = None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
) -> DataFrame: | ||
... | ||
|
||
|
@@ -327,7 +327,7 @@ def read_sql_query( | |
params=None, | ||
parse_dates=None, | ||
chunksize: int = 1, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
) -> Iterator[DataFrame]: | ||
... | ||
|
||
|
@@ -340,7 +340,7 @@ def read_sql_query( | |
params=None, | ||
parse_dates=None, | ||
chunksize: Optional[int] = None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
) -> Union[DataFrame, Iterator[DataFrame]]: | ||
""" | ||
Read SQL query into a DataFrame. | ||
|
@@ -1319,7 +1319,7 @@ def _query_iterator( | |
index_col=None, | ||
coerce_float=True, | ||
parse_dates=None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
): | ||
"""Return generator through chunked result set""" | ||
while True: | ||
|
@@ -1344,7 +1344,7 @@ def read_query( | |
parse_dates=None, | ||
params=None, | ||
chunksize: Optional[int] = None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
): | ||
""" | ||
Read SQL query into a DataFrame. | ||
|
@@ -1380,6 +1380,8 @@ def read_query( | |
Data type for data or columns. E.g. np.float64 or | ||
{‘a’: np.float64, ‘b’: np.int32, ‘c’: ‘Int64’} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. versionadded 1.3 |
||
|
||
.. versionadded:: 1.3.0 | ||
|
||
Returns | ||
------- | ||
DataFrame | ||
|
@@ -1819,7 +1821,7 @@ def _query_iterator( | |
index_col=None, | ||
coerce_float: bool = True, | ||
parse_dates=None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
): | ||
"""Return generator through chunked result set""" | ||
while True: | ||
|
@@ -1847,7 +1849,7 @@ def read_query( | |
params=None, | ||
parse_dates=None, | ||
chunksize: Optional[int] = None, | ||
dtype: DtypeArg = None, | ||
dtype: Optional[DtypeArg] = None, | ||
): | ||
|
||
args = _convert_params(sql, params) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment on what DtypeArg is / supposed to be used