-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Fix flake8 issues with whatsnew v0.18.* #24303
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
Changes from 2 commits
67ff7ae
7e4bc37
f898da7
2d7d5e5
c3fd30f
a17fa1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -53,6 +53,7 @@ Friday before MLK Day | |||||
|
||||||
.. ipython:: python | ||||||
|
||||||
from datetime import datetime | ||||||
dt = datetime(2014, 1, 17, 15) | ||||||
|
||||||
dt + bhour_us | ||||||
|
@@ -171,8 +172,7 @@ without using temporary variable. | |||||
bb = pd.read_csv('data/baseball.csv', index_col='id') | ||||||
(bb.groupby(['year', 'team']) | ||||||
.sum() | ||||||
.loc[lambda df: df.r > 100] | ||||||
) | ||||||
.loc[lambda df: df.r > 100]) | ||||||
|
||||||
.. _whatsnew_0181.partial_string_indexing: | ||||||
|
||||||
|
@@ -185,10 +185,11 @@ Partial string indexing now matches on ``DateTimeIndex`` when part of a ``MultiI | |||||
|
||||||
dft2 = pd.DataFrame(np.random.randn(20, 1), | ||||||
columns=['A'], | ||||||
index=pd.MultiIndex.from_product([pd.date_range('20130101', | ||||||
periods=10, | ||||||
freq='12H'), | ||||||
['a', 'b']])) | ||||||
index=pd.MultiIndex. | ||||||
from_product([pd.date_range('20130101', | ||||||
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. I found this indentation confusing. If the lines are too long, can we use something like:
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. Thanks for the comment. I wasn't flexible with that. I'll fix it. |
||||||
periods=10, | ||||||
freq='12H'), | ||||||
['a', 'b']])) | ||||||
dft2 | ||||||
dft2.loc['2013-01-05'] | ||||||
|
||||||
|
@@ -317,8 +318,8 @@ The index in ``.groupby(..).nth()`` output is now more consistent when the ``as_ | |||||
|
||||||
.. ipython:: python | ||||||
|
||||||
df = DataFrame({'A' : ['a', 'b', 'a'], | ||||||
'B' : [1, 2, 3]}) | ||||||
df = pd.DataFrame({'A': ['a', 'b', 'a'], | ||||||
'B': [1, 2, 3]}) | ||||||
df | ||||||
|
||||||
Previous Behavior: | ||||||
|
@@ -433,13 +434,15 @@ Previous behavior: | |||||
|
||||||
.. code-block:: ipython | ||||||
|
||||||
In [1]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x.value.sum()) | ||||||
In [1]: df.groupby(pd.TimeGrouper(key='date', | ||||||
...: freq='M')).apply(lambda x: x.value.sum()) | ||||||
Out[1]: | ||||||
... | ||||||
TypeError: cannot concatenate a non-NDFrame object | ||||||
|
||||||
# Output is a Series | ||||||
In [2]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x[['value']].sum()) | ||||||
In [2]: df.groupby(pd.TimeGrouper(key='date', | ||||||
...: freq='M')).apply(lambda x: x[['value']].sum()) | ||||||
Out[2]: | ||||||
date | ||||||
2000-10-31 value 10 | ||||||
|
@@ -451,15 +454,17 @@ New Behavior: | |||||
.. code-block:: python | ||||||
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.
Suggested change
|
||||||
|
||||||
# Output is a Series | ||||||
In [55]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x.value.sum()) | ||||||
In [55]: df.groupby(pd.TimeGrouper(key='date', | ||||||
...: freq='M')).apply(lambda x: x.value.sum()) | ||||||
Out[55]: | ||||||
date | ||||||
2000-10-31 10 | ||||||
2000-11-30 13 | ||||||
Freq: M, dtype: int64 | ||||||
|
||||||
# Output is a DataFrame | ||||||
In [56]: df.groupby(pd.TimeGrouper(key='date', freq='M')).apply(lambda x: x[['value']].sum()) | ||||||
In [56]: df.groupby(pd.TimeGrouper(key='date', | ||||||
...: freq='M')).apply(lambda x: x[['value']].sum()) | ||||||
Out[56]: | ||||||
value | ||||||
date | ||||||
|
@@ -471,6 +476,11 @@ New Behavior: | |||||
Changes in ``read_csv`` exceptions | ||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||||
|
||||||
.. ipython:: python | ||||||
:suppress: | ||||||
|
||||||
from io import StringIO | ||||||
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. can you use 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. Sure. I'll fix it. |
||||||
|
||||||
In order to standardize the ``read_csv`` API for both the ``c`` and ``python`` engines, both will now raise an | ||||||
``EmptyDataError``, a subclass of ``ValueError``, in response to empty columns or header (:issue:`12493`, :issue:`12506`) | ||||||
|
||||||
|
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 use
import datetime
instead, and usedatetime.datetime(...)
belowThere 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.
Sure. May I ask why you prefer that?
Is that because it can cause some namespace issues?
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.
There are many reasons, and some are not trivial to explain.
The main one is that if I see a bare
datetime
in Python code, I need to guess whether it's the main module, or thedatetime.datetime
module. While there is no ambiguity in readingdatetime.datetime
.Then, with a
from datetime import datetime
I load the wholedatetime
module insys.modules
, but I only have access in the namespace to thedatetime.datetime
submodule (with the namedatetime
). This won't let me perform operations likeimp.reload(datetime)
, as I don't have anything in the namespace pointing to the maindatetime
module.