Skip to content

DEPR: Deprecate numpy argument in read_json #28562

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

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5a5b347
add original changes.
lucaionescu Dec 18, 2019
18bd98f
ENH: Add support for DataFrame(Categorical) (#11363) (#30305)
proost Dec 18, 2019
416907d
DOC: whatsnew fixups (#30331)
TomAugspurger Dec 18, 2019
f36eac1
CLN: changed .format to f-string in pandas/core/dtypes (#30287)
DorAmram Dec 18, 2019
70a083f
Fix typos, via a Levenshtein-style corrector (#30341)
bwignall Dec 19, 2019
20e4c18
TYPING: Enable --check-untyped-defs for MyPy (#29493)
simonjayhawkins Dec 19, 2019
53a0dfd
BUG: Fix infer_dtype_from_scalar to infer IntervalDtype (#30339)
jschendel Dec 19, 2019
5b25df2
API: Return BoolArray for string ops when backed by StringArray (#30239)
TomAugspurger Dec 19, 2019
f8b9ce7
REF: change parameter name fname -> path (#30338)
jbrockmendel Dec 19, 2019
8cbfd06
CLN: make lookups explicit instead of using globals (#30343)
jbrockmendel Dec 19, 2019
2bfd10c
REF: remove pytables Table.metadata (#30342)
jbrockmendel Dec 19, 2019
95e1a63
REF: pytables prepare to make _create_axes return a new object (#30344)
jbrockmendel Dec 19, 2019
e66a2c7
CLN: format replaced with f-strings #29547 (#30355)
hasnain2808 Dec 19, 2019
011a667
replace str.format with f-string (#30363)
AlpAribal Dec 20, 2019
c521a4e
DOC: "Next" link from user_guide/io.rst goes to read_sql_table API pa…
souvik3333 Dec 20, 2019
b4343ef
CI: troubleshoot codecov (#30070)
jbrockmendel Dec 20, 2019
66038e9
BUG+TST: non-optimized apply_index and empty DatetimeIndex (#30336)
jbrockmendel Dec 20, 2019
a9e2566
REF: define NA_VALUES in libparsers (#30373)
jbrockmendel Dec 20, 2019
eadaa40
[CLN] remove now-unnecessary td.skip_if_no(pathlib) (#30376)
MarcoGorelli Dec 20, 2019
1be80ea
REF: directory for method-specific series/frame tests (#30362)
jbrockmendel Dec 20, 2019
a6b047a
REF: refactor cumulative op tests from test_analytics (#30358)
jbrockmendel Dec 20, 2019
9296849
Cleaned up Tempita refs and Cython import (#30330)
WillAyd Dec 20, 2019
6efc237
CLN: Old string formatting: .format() -> f"" (#30328)
baevpetr Dec 20, 2019
0df8858
de-privatize io.common functions (#30368)
jbrockmendel Dec 20, 2019
0cd388f
CLN: remove py2-legacy UnicodeReader, UnicodeWriter (#30371)
jbrockmendel Dec 20, 2019
8376067
CI: troubleshoot codecov (#30380)
jbrockmendel Dec 21, 2019
c869255
CLN: move code out of try clause in merge.py (#30382)
topper-123 Dec 21, 2019
477b2d5
TYP: Annotations in core/indexes/ (#30390)
ShaharNaveh Dec 21, 2019
835f207
DOC: fix external links + favicon (#30389)
jorisvandenbossche Dec 22, 2019
a2bbdb5
STY: Underscores for long numbers (#30397)
ShaharNaveh Dec 22, 2019
104fc11
fix call of tm.assert_frame_equal
lucaionescu Dec 22, 2019
97b182b
add original changes.
lucaionescu Dec 18, 2019
3c8f95b
fix call of tm.assert_frame_equal
lucaionescu Dec 22, 2019
df2671b
merge.
lucaionescu Dec 22, 2019
f46426e
Revert "fix call of tm.assert_frame_equal"
lucaionescu Dec 22, 2019
0be5dd7
Revert "merge."
lucaionescu Dec 22, 2019
16217f0
fix tm.assert_frame_equal. use naming conventions.
lucaionescu Dec 22, 2019
640f729
sort imports correctly.
lucaionescu Dec 22, 2019
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
Prev Previous commit
Next Next commit
STY: Underscores for long numbers (#30397)
  • Loading branch information
ShaharNaveh authored and topper-123 committed Dec 22, 2019
commit a2bbdb5a0abd131d0190fe58c0ba7cbf21b960c9
25 changes: 18 additions & 7 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,22 @@ class Timestamp(_Timestamp):
"""
return cls(datetime.combine(date, time))

def __new__(cls, object ts_input=_no_input,
object freq=None, tz=None, unit=None,
year=None, month=None, day=None,
hour=None, minute=None, second=None, microsecond=None,
nanosecond=None, tzinfo=None):
def __new__(
cls,
object ts_input=_no_input,
object freq=None,
tz=None,
unit=None,
year=None,
month=None,
day=None,
hour=None,
minute=None,
second=None,
microsecond=None,
nanosecond=None,
tzinfo=None
):
# The parameter list folds together legacy parameter names (the first
# four) and positional and keyword parameter names from pydatetime.
#
Expand Down Expand Up @@ -401,8 +412,8 @@ class Timestamp(_Timestamp):
freq = None

if getattr(ts_input, 'tzinfo', None) is not None and tz is not None:
raise ValueError("Cannot pass a datetime or Timestamp with tzinfo with the"
" tz parameter. Use tz_convert instead.")
raise ValueError("Cannot pass a datetime or Timestamp with tzinfo with "
"the tz parameter. Use tz_convert instead.")

ts = convert_to_tsobject(ts_input, tz, unit, 0, 0, nanosecond or 0)

Expand Down
56 changes: 28 additions & 28 deletions pandas/tests/scalar/timestamp/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,17 @@ class TestTimestampConstructors:
def test_constructor(self):
base_str = "2014-07-01 09:00"
base_dt = datetime(2014, 7, 1, 9)
base_expected = 1404205200000000000
base_expected = 1_404_205_200_000_000_000

# confirm base representation is correct
assert calendar.timegm(base_dt.timetuple()) * 1000000000 == base_expected
assert calendar.timegm(base_dt.timetuple()) * 1_000_000_000 == base_expected

tests = [
(base_str, base_dt, base_expected),
(
"2014-07-01 10:00",
datetime(2014, 7, 1, 10),
base_expected + 3600 * 1000000000,
base_expected + 3600 * 1_000_000_000,
),
(
"2014-07-01 09:00:00.000008000",
Expand Down Expand Up @@ -250,7 +250,7 @@ def test_constructor(self):
# with timezone
for tz, offset in timezones:
for result in [Timestamp(date_str, tz=tz), Timestamp(date, tz=tz)]:
expected_tz = expected - offset * 3600 * 1000000000
expected_tz = expected - offset * 3600 * 1_000_000_000
assert result.value == expected_tz
assert conversion.pydt_to_i8(result) == expected_tz

Expand All @@ -264,22 +264,22 @@ def test_constructor(self):
result = Timestamp(result).tz_convert("UTC")
else:
result = Timestamp(result, tz="UTC")
expected_utc = expected - offset * 3600 * 1000000000
expected_utc = expected - offset * 3600 * 1_000_000_000
assert result.value == expected_utc
assert conversion.pydt_to_i8(result) == expected_utc

def test_constructor_with_stringoffset(self):
# GH 7833
base_str = "2014-07-01 11:00:00+02:00"
base_dt = datetime(2014, 7, 1, 9)
base_expected = 1404205200000000000
base_expected = 1_404_205_200_000_000_000

# confirm base representation is correct
assert calendar.timegm(base_dt.timetuple()) * 1000000000 == base_expected
assert calendar.timegm(base_dt.timetuple()) * 1_000_000_000 == base_expected

tests = [
(base_str, base_expected),
("2014-07-01 12:00:00+02:00", base_expected + 3600 * 1000000000),
("2014-07-01 12:00:00+02:00", base_expected + 3600 * 1_000_000_000),
("2014-07-01 11:00:00.000008000+02:00", base_expected + 8000),
("2014-07-01 11:00:00.000000005+02:00", base_expected + 5),
]
Expand Down Expand Up @@ -725,7 +725,7 @@ def test_utc_z_designator(self):
assert get_timezone(Timestamp("2014-11-02 01:00Z").tzinfo) is utc

def test_asm8(self):
np.random.seed(7960929)
np.random.seed(7_960_929)
ns = [Timestamp.min.value, Timestamp.max.value, 1000]

for n in ns:
Expand Down Expand Up @@ -786,15 +786,15 @@ def compare(x, y):
)

def test_basics_nanos(self):
val = np.int64(946684800000000000).view("M8[ns]")
val = np.int64(946_684_800_000_000_000).view("M8[ns]")
stamp = Timestamp(val.view("i8") + 500)
assert stamp.year == 2000
assert stamp.month == 1
assert stamp.microsecond == 0
assert stamp.nanosecond == 500

# GH 14415
val = np.iinfo(np.int64).min + 80000000000000
val = np.iinfo(np.int64).min + 80_000_000_000_000
stamp = Timestamp(val)
assert stamp.year == 1677
assert stamp.month == 9
Expand All @@ -807,8 +807,8 @@ def test_basics_nanos(self):
[
[946688461000000000, {}],
[946688461000000000 / 1000, dict(unit="us")],
[946688461000000000 / 1000000, dict(unit="ms")],
[946688461000000000 / 1000000000, dict(unit="s")],
[946688461000000000 / 1_000_000, dict(unit="ms")],
[946688461000000000 / 1_000_000_000, dict(unit="s")],
[10957, dict(unit="D", h=0)],
[
(946688461000000000 + 500000) / 1000000000,
Expand Down Expand Up @@ -852,24 +852,24 @@ def test_roundtrip(self):
base = Timestamp("20140101 00:00:00")

result = Timestamp(base.value + Timedelta("5ms").value)
assert result == Timestamp(str(base) + ".005000")
assert result == Timestamp(f"{base}.005000")
assert result.microsecond == 5000

result = Timestamp(base.value + Timedelta("5us").value)
assert result == Timestamp(str(base) + ".000005")
assert result == Timestamp(f"{base}.000005")
assert result.microsecond == 5

result = Timestamp(base.value + Timedelta("5ns").value)
assert result == Timestamp(str(base) + ".000000005")
assert result == Timestamp(f"{base}.000000005")
assert result.nanosecond == 5
assert result.microsecond == 0

result = Timestamp(base.value + Timedelta("6ms 5us").value)
assert result == Timestamp(str(base) + ".006005")
assert result == Timestamp(f"{base}.006005")
assert result.microsecond == 5 + 6 * 1000

result = Timestamp(base.value + Timedelta("200ms 5us").value)
assert result == Timestamp(str(base) + ".200005")
assert result == Timestamp(f"{base}.200005")
assert result.microsecond == 5 + 200 * 1000

def test_hash_equivalent(self):
Expand All @@ -890,20 +890,20 @@ def test_nanosecond_string_parsing(self):
ts = Timestamp("2013-05-01 07:15:45.123456789")
# GH 7878
expected_repr = "2013-05-01 07:15:45.123456789"
expected_value = 1367392545123456789
expected_value = 1_367_392_545_123_456_789
assert ts.value == expected_value
assert expected_repr in repr(ts)

ts = Timestamp("2013-05-01 07:15:45.123456789+09:00", tz="Asia/Tokyo")
assert ts.value == expected_value - 9 * 3600 * 1000000000
assert ts.value == expected_value - 9 * 3600 * 1_000_000_000
assert expected_repr in repr(ts)

ts = Timestamp("2013-05-01 07:15:45.123456789", tz="UTC")
assert ts.value == expected_value
assert expected_repr in repr(ts)

ts = Timestamp("2013-05-01 07:15:45.123456789", tz="US/Eastern")
assert ts.value == expected_value + 4 * 3600 * 1000000000
assert ts.value == expected_value + 4 * 3600 * 1_000_000_000
assert expected_repr in repr(ts)

# GH 10041
Expand All @@ -913,7 +913,7 @@ def test_nanosecond_string_parsing(self):

def test_nanosecond_timestamp(self):
# GH 7610
expected = 1293840000000000005
expected = 1_293_840_000_000_000_005
t = Timestamp("2011-01-01") + offsets.Nano(5)
assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
assert t.value == expected
Expand All @@ -929,7 +929,7 @@ def test_nanosecond_timestamp(self):
assert t.value == expected
assert t.nanosecond == 5

expected = 1293840000000000010
expected = 1_293_840_000_000_000_010
t = t + offsets.Nano(5)
assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
assert t.value == expected
Expand All @@ -949,23 +949,23 @@ def test_nanosecond_timestamp(self):
class TestTimestampToJulianDate:
def test_compare_1700(self):
r = Timestamp("1700-06-23").to_julian_date()
assert r == 2342145.5
assert r == 2_342_145.5

def test_compare_2000(self):
r = Timestamp("2000-04-12").to_julian_date()
assert r == 2451646.5
assert r == 2_451_646.5

def test_compare_2100(self):
r = Timestamp("2100-08-12").to_julian_date()
assert r == 2488292.5
assert r == 2_488_292.5

def test_compare_hour01(self):
r = Timestamp("2000-08-12T01:00:00").to_julian_date()
assert r == 2451768.5416666666666666
assert r == 2_451_768.5416666666666666

def test_compare_hour13(self):
r = Timestamp("2000-08-12T13:00:00").to_julian_date()
assert r == 2451769.0416666666666666
assert r == 2_451_769.0416666666666666


class TestTimestampConversion:
Expand Down