Skip to content

CLN: Remove unicode u string prefix #25864

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 2 commits into from
Mar 25, 2019
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
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
master_doc = 'index'

# General information about the project.
project = u'pandas'
copyright = u'2008-2014, the pandas development team'
project = 'pandas'
copyright = '2008-2014, the pandas development team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ values **not** in the categories, similarly to how you can reindex **any** panda
In [11]: df3 = df3.set_index('B')

In [11]: df3.index
Out[11]: CategoricalIndex([u'a', u'a', u'b', u'b', u'c', u'a'], categories=[u'a', u'b', u'c'], ordered=False, name=u'B', dtype='category')
Out[11]: CategoricalIndex(['a', 'a', 'b', 'b', 'c', 'a'], categories=['a', 'b', 'c'], ordered=False, name='B', dtype='category')

In [12]: pd.concat([df2, df3])
TypeError: categories must match existing categories when appending
Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ If a DataFrame or Series contains these characters, the default output mode may

.. ipython:: python

df = pd.DataFrame({u'国籍': ['UK', u'日本'], u'名前': ['Alice', u'しのぶ']})
df = pd.DataFrame({'国籍': ['UK', '日本'], '名前': ['Alice', 'しのぶ']})
df

.. image:: ../_static/option_unicode01.png
Expand All @@ -507,7 +507,7 @@ By default, an "Ambiguous" character's width, such as "¡" (inverted exclamation

.. ipython:: python

df = pd.DataFrame({'a': ['xxx', u'¡¡'], 'b': ['yyy', u'¡¡']})
df = pd.DataFrame({'a': ['xxx', '¡¡'], 'b': ['yyy', '¡¡']})
df

.. image:: ../_static/option_unicode03.png
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ handling of NaN:
In [2]: pd.factorize(x, sort=True)
Out[2]:
(array([ 2, 2, -1, 3, 0, 1]),
Index([3.14, inf, u'A', u'B'], dtype='object'))
Index([3.14, inf, 'A', 'B'], dtype='object'))

In [3]: np.unique(x, return_inverse=True)[::-1]
Out[3]: (array([3, 3, 0, 4, 1, 2]), array([nan, 3.14, inf, 'A', 'B'], dtype=object))
Expand Down
10 changes: 5 additions & 5 deletions doc/sphinxext/announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@


def get_authors(revision_range):
pat = u'^.*\\t(.*)$'
pat = '^.*\\t(.*)$'
lst_release, cur_release = [r.strip() for r in revision_range.split('..')]

# authors, in current release and previous to current release.
Expand All @@ -70,7 +70,7 @@ def get_authors(revision_range):
pre.discard('Homu')

# Append '+' to new authors.
authors = [s + u' +' for s in cur - pre] + [s for s in cur & pre]
authors = [s + ' +' for s in cur - pre] + [s for s in cur & pre]
authors.sort()
return authors

Expand All @@ -81,17 +81,17 @@ def get_pull_requests(repo, revision_range):
# From regular merges
merges = this_repo.git.log(
'--oneline', '--merges', revision_range)
issues = re.findall(u"Merge pull request \\#(\\d*)", merges)
issues = re.findall("Merge pull request \\#(\\d*)", merges)
prnums.extend(int(s) for s in issues)

# From Homu merges (Auto merges)
issues = re. findall(u"Auto merge of \\#(\\d*)", merges)
issues = re. findall("Auto merge of \\#(\\d*)", merges)
prnums.extend(int(s) for s in issues)

# From fast forward squash-merges
commits = this_repo.git.log(
'--oneline', '--no-merges', '--first-parent', revision_range)
issues = re.findall(u'^.*\\(\\#(\\d+)\\)$', commits, re.M)
issues = re.findall('^.*\\(\\#(\\d+)\\)$', commits, re.M)
prnums.extend(int(s) for s in issues)

# get PR data from github repo
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,16 +839,16 @@ def __repr__(self):
from pandas.io.formats.printing import format_object_summary

template = (
u'{class_name}'
u'{data}\n'
u'Length: {length}, dtype: {dtype}'
'{class_name}'
'{data}\n'
'Length: {length}, dtype: {dtype}'
)
# the short repr has no trailing newline, while the truncated
# repr does. So we include a newline in our template, and strip
# any trailing newlines from format_object_summary
data = format_object_summary(self, self._formatter(),
indent_for_name=False).rstrip(', \n')
class_name = u'<{}>\n'.format(self.__class__.__name__)
class_name = '<{}>\n'.format(self.__class__.__name__)
return template.format(class_name=class_name, data=data,
length=len(self),
dtype=self.dtype)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ def _reverse_indexer(self):
Categories (3, object): [a, b, c]

In [3]: c.categories
Out[3]: Index([u'a', u'b', u'c'], dtype='object')
Out[3]: Index(['a', 'b', 'c'], dtype='object')

In [4]: c.codes
Out[4]: array([0, 0, 1, 2, 0], dtype=int8)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def asfreq(self, freq=None, how='E'):
# ------------------------------------------------------------------
# Rendering Methods

def _format_native_types(self, na_rep=u'NaT', date_format=None, **kwargs):
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs):
"""
actually format my specific types
"""
Expand All @@ -485,7 +485,7 @@ def _format_native_types(self, na_rep=u'NaT', date_format=None, **kwargs):
if date_format:
formatter = lambda dt: dt.strftime(date_format)
else:
formatter = lambda dt: u'%s' % dt
formatter = lambda dt: '%s' % dt

if self._hasnans:
mask = self._isnan
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ def __init__(self, value, converted, kind):
def tostring(self, encoding):
""" quote the string if not encoded
else encode and return """
if self.kind == u'string':
if self.kind == 'string':
if encoding is not None:
return self.converted
return '"{converted}"'.format(converted=self.converted)
elif self.kind == u'float':
elif self.kind == 'float':
# python 2 str(float) is not always
# round-trippable so use repr()
return repr(self.converted)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ def __eq__(self, other):
return hash(self) == hash(other)

def __repr__(self):
tpl = u'CategoricalDtype(categories={}ordered={})'
tpl = 'CategoricalDtype(categories={}ordered={})'
if self.categories is None:
data = u"None, "
data = "None, "
else:
data = self.categories._format_data(name=self.__class__.__name__)
return tpl.format(data, self.ordered)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8063,4 +8063,4 @@ def _from_nested_dict(data):


def _put_str(s, space):
return u'{s}'.format(s=s)[:space].ljust(space)
return '{s}'.format(s=s)[:space].ljust(space)
50 changes: 25 additions & 25 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ def from_tuples(cls, tuples, sortorder=None, names=None):

Examples
--------
>>> tuples = [(1, u'red'), (1, u'blue'),
... (2, u'red'), (2, u'blue')]
>>> tuples = [(1, 'red'), (1, 'blue'),
... (2, 'red'), (2, 'blue')]
>>> pd.MultiIndex.from_tuples(tuples, names=('number', 'color'))
MultiIndex(levels=[[1, 2], ['blue', 'red']],
codes=[[0, 0, 1, 1], [1, 0, 1, 0]],
Expand Down Expand Up @@ -621,25 +621,25 @@ def set_levels(self, levels, level=None, inplace=False,

Examples
--------
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
(2, u'one'), (2, u'two')],
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
(2, 'one'), (2, 'two')],
names=['foo', 'bar'])
>>> idx.set_levels([['a','b'], [1,2]])
MultiIndex(levels=[[u'a', u'b'], [1, 2]],
MultiIndex(levels=[['a', 'b'], [1, 2]],
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
>>> idx.set_levels(['a','b'], level=0)
MultiIndex(levels=[[u'a', u'b'], [u'one', u'two']],
MultiIndex(levels=[['a', 'b'], ['one', 'two']],
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
>>> idx.set_levels(['a','b'], level='bar')
MultiIndex(levels=[[1, 2], [u'a', u'b']],
MultiIndex(levels=[[1, 2], ['a', 'b']],
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
>>> idx.set_levels([['a','b'], [1,2]], level=[0,1])
MultiIndex(levels=[[u'a', u'b'], [1, 2]],
MultiIndex(levels=[['a', 'b'], [1, 2]],
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
"""
if is_list_like(levels) and not isinstance(levels, Index):
levels = list(levels)
Expand Down Expand Up @@ -740,25 +740,25 @@ def set_codes(self, codes, level=None, inplace=False,

Examples
--------
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
(2, u'one'), (2, u'two')],
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
(2, 'one'), (2, 'two')],
names=['foo', 'bar'])
>>> idx.set_codes([[1,0,1,0], [0,0,1,1]])
MultiIndex(levels=[[1, 2], [u'one', u'two']],
MultiIndex(levels=[[1, 2], ['one', 'two']],
codes=[[1, 0, 1, 0], [0, 0, 1, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
>>> idx.set_codes([1,0,1,0], level=0)
MultiIndex(levels=[[1, 2], [u'one', u'two']],
MultiIndex(levels=[[1, 2], ['one', 'two']],
codes=[[1, 0, 1, 0], [0, 1, 0, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
>>> idx.set_codes([0,0,1,1], level='bar')
MultiIndex(levels=[[1, 2], [u'one', u'two']],
MultiIndex(levels=[[1, 2], ['one', 'two']],
codes=[[0, 0, 1, 1], [0, 0, 1, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
>>> idx.set_codes([[1,0,1,0], [0,0,1,1]], level=[0,1])
MultiIndex(levels=[[1, 2], [u'one', u'two']],
MultiIndex(levels=[[1, 2], ['one', 'two']],
codes=[[1, 0, 1, 0], [0, 0, 1, 1]],
names=[u'foo', u'bar'])
names=['foo', 'bar'])
"""
if level is not None and not is_list_like(level):
if not is_list_like(codes):
Expand Down Expand Up @@ -1512,10 +1512,10 @@ def to_hierarchical(self, n_repeat, n_shuffle=1):

Examples
--------
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
(2, u'one'), (2, u'two')])
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
(2, 'one'), (2, 'two')])
>>> idx.to_hierarchical(3)
MultiIndex(levels=[[1, 2], [u'one', u'two']],
MultiIndex(levels=[[1, 2], ['one', 'two']],
codes=[[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]])
"""
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def _maybe_convert_timedelta(self, other):
# ------------------------------------------------------------------------
# Rendering Methods

def _format_native_types(self, na_rep=u'NaT', quoting=None, **kwargs):
def _format_native_types(self, na_rep='NaT', quoting=None, **kwargs):
# just dispatch, return ndarray
return self._data._format_native_types(na_rep=na_rep,
quoting=quoting,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ def _validate_read_indexer(self, key, indexer, axis, raise_missing=False):
if missing:
if missing == len(indexer):
raise KeyError(
u"None of [{key}] are in the [{axis}]".format(
"None of [{key}] are in the [{axis}]".format(
key=key, axis=self.obj._get_axis_name(axis)))

# We (temporarily) allow for some missing keys with .loc, except in
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ def __unicode__(self):
output = pprint_thing(self.__class__.__name__)
for i, ax in enumerate(self.axes):
if i == 0:
output += u'\nItems: {ax}'.format(ax=ax)
output += '\nItems: {ax}'.format(ax=ax)
else:
output += u'\nAxis {i}: {ax}'.format(i=i, ax=ax)
output += '\nAxis {i}: {ax}'.format(i=i, ax=ax)

for block in self.blocks:
output += u'\n{block}'.format(block=pprint_thing(block))
output += '\n{block}'.format(block=pprint_thing(block))
return output

def _verify_integrity(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _add_margins(table, data, values, rows, cols, aggfunc,
if not isinstance(margins_name, compat.string_types):
raise ValueError('margins_name argument must be a string')

msg = u'Conflicting name "{name}" in margins'.format(name=margins_name)
msg = 'Conflicting name "{name}" in margins'.format(name=margins_name)
for level in table.index.names:
if margins_name in table.index.get_level_values(level):
raise ValueError(msg)
Expand Down
2 changes: 1 addition & 1 deletion pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ParserWarning(Warning):
Using a `sep` in `pd.read_csv` other than a single character:

>>> import io
>>> csv = u'''a;b;c
>>> csv = '''a;b;c
... 1;1,8
... 1;2,1'''
>>> df = pd.read_csv(io.StringIO(csv), sep='[;,]') # doctest: +SKIP
Expand Down
14 changes: 7 additions & 7 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _get_footer(self):

series_name = pprint_thing(name,
escape_chars=('\t', '\r', '\n'))
footer += ((u"Name: {sname}".format(sname=series_name))
footer += (("Name: {sname}".format(sname=series_name))
if name is not None else "")

if (self.length is True or
Expand All @@ -227,7 +227,7 @@ def _get_footer(self):
if name:
if footer:
footer += ', '
footer += u'dtype: {typ}'.format(typ=pprint_thing(name))
footer += 'dtype: {typ}'.format(typ=pprint_thing(name))

# level infos are added to the end and in a new line, like it is done
# for Categoricals
Expand Down Expand Up @@ -949,10 +949,10 @@ def _format(x):
return 'NaT'
return self.na_rep
elif isinstance(x, PandasObject):
return u'{x}'.format(x=x)
return '{x}'.format(x=x)
else:
# object dtype
return u'{x}'.format(x=formatter(x))
return '{x}'.format(x=formatter(x))

vals = self.values
if isinstance(vals, Index):
Expand All @@ -968,16 +968,16 @@ def _format(x):
fmt_values = []
for i, v in enumerate(vals):
if not is_float_type[i] and leading_space:
fmt_values.append(u' {v}'.format(v=_format(v)))
fmt_values.append(' {v}'.format(v=_format(v)))
elif is_float_type[i]:
fmt_values.append(float_format(v))
else:
if leading_space is False:
# False specifically, so that the default is
# to include a space if we get here.
tpl = u'{v}'
tpl = '{v}'
else:
tpl = u' {v}'
tpl = ' {v}'
fmt_values.append(tpl.format(v=_format(v)))

return fmt_values
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _write_cell(self, s, kind='td', indent=0, tags=None):
else:
end_a = ''

self.write(u'{start}{rs}{end_a}</{kind}>'.format(
self.write('{start}{rs}{end_a}</{kind}>'.format(
start=start_tag, rs=rs, end_a=end_a, kind=kind), indent)

def write_tr(self, line, indent=0, indent_delta=0, header=False,
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/formats/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,17 @@ def best_len(values):
else:
return 0

close = u', '
close = ', '

if n == 0:
summary = u'[]{}'.format(close)
summary = '[]{}'.format(close)
elif n == 1:
first = formatter(obj[0])
summary = u'[{}]{}'.format(first, close)
summary = '[{}]{}'.format(first, close)
elif n == 2:
first = formatter(obj[0])
last = formatter(obj[-1])
summary = u'[{}, {}]{}'.format(first, last, close)
summary = '[{}, {}]{}'.format(first, last, close)
else:

if n > max_seq_items:
Expand Down
Loading