Skip to content

CLN: make tm.N, tm.K private #32138

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 1 commit into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 2 additions & 6 deletions doc/source/user_guide/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Reshaping by pivoting DataFrame objects
:suppress:

import pandas._testing as tm
tm.N = 3

def unpivot(frame):
N, K = frame.shape
Expand All @@ -27,7 +26,7 @@ Reshaping by pivoting DataFrame objects
columns = ['date', 'variable', 'value']
return pd.DataFrame(data, columns=columns)

df = unpivot(tm.makeTimeDataFrame())
df = unpivot(tm.makeTimeDataFrame(3))

Data is often stored in so-called "stacked" or "record" format:

Expand All @@ -42,9 +41,6 @@ For the curious here is how the above ``DataFrame`` was created:

import pandas._testing as tm

tm.N = 3


def unpivot(frame):
N, K = frame.shape
data = {'value': frame.to_numpy().ravel('F'),
Expand All @@ -53,7 +49,7 @@ For the curious here is how the above ``DataFrame`` was created:
return pd.DataFrame(data, columns=['date', 'variable', 'value'])


df = unpivot(tm.makeTimeDataFrame())
df = unpivot(tm.makeTimeDataFrame(3))

To select out everything for variable ``A`` we could do:

Expand Down
28 changes: 14 additions & 14 deletions pandas/_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

lzma = _import_lzma()

N = 30
K = 4
_N = 30
_K = 4
_RAISE_NETWORK_ERROR_DEFAULT = False

# set testing_mode
Expand Down Expand Up @@ -1794,45 +1794,45 @@ def all_timeseries_index_generator(k=10):

# make series
def makeFloatSeries(name=None):
index = makeStringIndex(N)
return Series(randn(N), index=index, name=name)
index = makeStringIndex(_N)
return Series(randn(_N), index=index, name=name)


def makeStringSeries(name=None):
index = makeStringIndex(N)
return Series(randn(N), index=index, name=name)
index = makeStringIndex(_N)
return Series(randn(_N), index=index, name=name)


def makeObjectSeries(name=None):
data = makeStringIndex(N)
data = makeStringIndex(_N)
data = Index(data, dtype=object)
index = makeStringIndex(N)
index = makeStringIndex(_N)
return Series(data, index=index, name=name)


def getSeriesData():
index = makeStringIndex(N)
return {c: Series(randn(N), index=index) for c in getCols(K)}
index = makeStringIndex(_N)
return {c: Series(randn(_N), index=index) for c in getCols(_K)}


def makeTimeSeries(nper=None, freq="B", name=None):
if nper is None:
nper = N
nper = _N
return Series(randn(nper), index=makeDateIndex(nper, freq=freq), name=name)


def makePeriodSeries(nper=None, name=None):
if nper is None:
nper = N
nper = _N
return Series(randn(nper), index=makePeriodIndex(nper), name=name)


def getTimeSeriesData(nper=None, freq="B"):
return {c: makeTimeSeries(nper, freq) for c in getCols(K)}
return {c: makeTimeSeries(nper, freq) for c in getCols(_K)}


def getPeriodData(nper=None):
return {c: makePeriodSeries(nper) for c in getCols(K)}
return {c: makePeriodSeries(nper) for c in getCols(_K)}


# make frame
Expand Down