Skip to content
Closed
Changes from 1 commit
Commits
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
CLN: remove impossible "Index is None" case
  • Loading branch information
toobaz committed Apr 2, 2018
commit 14f04435393e70ab1c57a85c860d913e22c661c5
3 changes: 0 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4111,9 +4111,6 @@ def _try_cast(arr, take_fast_path):
subarr = _try_cast(data, False)

if subarr.ndim == 0 or is_scalar(data):
if index is None:
return subarr.item()

if subarr.ndim == 1:
# a scalar upcasted to 1-dimensional by maybe_cast_to_datetime()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so would much rather fix this case inside maybe_cast_to_datetime

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My (limited) understanding is that it is impossible, basically because

def broken_datetimeindex_roundtrip(dtix): scalar = dtix.values[0, ...] return pd.DatetimeIndex(np.array([scalar], dtype=scalar.dtype))

looses tz and freq.
This in turn is probably not trivial at all to fix (or more honestly: I have no idea).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looses tz and freq.

Uhm... it probably makes perfect sense that it looses freq (but not tz).

value = subarr[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this branch ever hit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pd.Series(pd.Timestamp('2015-10-10'), index=range(3))

Expand Down