Skip to content

Commit d8642e9

Browse files
jschendeljreback
authored andcommitted
CLN: Remove unicode u string prefix (#25864)
1 parent 758187f commit d8642e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+865
-865
lines changed

doc/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
master_doc = 'index'
135135

136136
# General information about the project.
137-
project = u'pandas'
138-
copyright = u'2008-2014, the pandas development team'
137+
project = 'pandas'
138+
copyright = '2008-2014, the pandas development team'
139139

140140
# The version info for the project you're documenting, acts as replacement for
141141
# |version| and |release|, also used in various other places throughout the

doc/source/user_guide/advanced.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ values **not** in the categories, similarly to how you can reindex **any** panda
797797
In [11]: df3 = df3.set_index('B')
798798
799799
In [11]: df3.index
800-
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')
800+
Out[11]: CategoricalIndex(['a', 'a', 'b', 'b', 'c', 'a'], categories=['a', 'b', 'c'], ordered=False, name='B', dtype='category')
801801
802802
In [12]: pd.concat([df2, df3])
803803
TypeError: categories must match existing categories when appending

doc/source/user_guide/options.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ If a DataFrame or Series contains these characters, the default output mode may
484484

485485
.. ipython:: python
486486
487-
df = pd.DataFrame({u'国籍': ['UK', u'日本'], u'名前': ['Alice', u'しのぶ']})
487+
df = pd.DataFrame({'国籍': ['UK', '日本'], '名前': ['Alice', 'しのぶ']})
488488
df
489489
490490
.. image:: ../_static/option_unicode01.png
@@ -507,7 +507,7 @@ By default, an "Ambiguous" character's width, such as "¡" (inverted exclamation
507507

508508
.. ipython:: python
509509
510-
df = pd.DataFrame({'a': ['xxx', u'¡¡'], 'b': ['yyy', u'¡¡']})
510+
df = pd.DataFrame({'a': ['xxx', '¡¡'], 'b': ['yyy', '¡¡']})
511511
df
512512
513513
.. image:: ../_static/option_unicode03.png

doc/source/user_guide/reshaping.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ handling of NaN:
695695
In [2]: pd.factorize(x, sort=True)
696696
Out[2]:
697697
(array([ 2, 2, -1, 3, 0, 1]),
698-
Index([3.14, inf, u'A', u'B'], dtype='object'))
698+
Index([3.14, inf, 'A', 'B'], dtype='object'))
699699
700700
In [3]: np.unique(x, return_inverse=True)[::-1]
701701
Out[3]: (array([3, 3, 0, 4, 1, 2]), array([nan, 3.14, inf, 'A', 'B'], dtype=object))

doc/sphinxext/announce.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757

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

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

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

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

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

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

9797
# get PR data from github repo

pandas/core/arrays/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,16 @@ def __repr__(self):
839839
from pandas.io.formats.printing import format_object_summary
840840

841841
template = (
842-
u'{class_name}'
843-
u'{data}\n'
844-
u'Length: {length}, dtype: {dtype}'
842+
'{class_name}'
843+
'{data}\n'
844+
'Length: {length}, dtype: {dtype}'
845845
)
846846
# the short repr has no trailing newline, while the truncated
847847
# repr does. So we include a newline in our template, and strip
848848
# any trailing newlines from format_object_summary
849849
data = format_object_summary(self, self._formatter(),
850850
indent_for_name=False).rstrip(', \n')
851-
class_name = u'<{}>\n'.format(self.__class__.__name__)
851+
class_name = '<{}>\n'.format(self.__class__.__name__)
852852
return template.format(class_name=class_name, data=data,
853853
length=len(self),
854854
dtype=self.dtype)

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ def _reverse_indexer(self):
21472147
Categories (3, object): [a, b, c]
21482148
21492149
In [3]: c.categories
2150-
Out[3]: Index([u'a', u'b', u'c'], dtype='object')
2150+
Out[3]: Index(['a', 'b', 'c'], dtype='object')
21512151
21522152
In [4]: c.codes
21532153
Out[4]: array([0, 0, 1, 2, 0], dtype=int8)

pandas/core/arrays/period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def asfreq(self, freq=None, how='E'):
476476
# ------------------------------------------------------------------
477477
# Rendering Methods
478478

479-
def _format_native_types(self, na_rep=u'NaT', date_format=None, **kwargs):
479+
def _format_native_types(self, na_rep='NaT', date_format=None, **kwargs):
480480
"""
481481
actually format my specific types
482482
"""
@@ -485,7 +485,7 @@ def _format_native_types(self, na_rep=u'NaT', date_format=None, **kwargs):
485485
if date_format:
486486
formatter = lambda dt: dt.strftime(date_format)
487487
else:
488-
formatter = lambda dt: u'%s' % dt
488+
formatter = lambda dt: '%s' % dt
489489

490490
if self._hasnans:
491491
mask = self._isnan

pandas/core/computation/pytables.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,11 @@ def __init__(self, value, converted, kind):
584584
def tostring(self, encoding):
585585
""" quote the string if not encoded
586586
else encode and return """
587-
if self.kind == u'string':
587+
if self.kind == 'string':
588588
if encoding is not None:
589589
return self.converted
590590
return '"{converted}"'.format(converted=self.converted)
591-
elif self.kind == u'float':
591+
elif self.kind == 'float':
592592
# python 2 str(float) is not always
593593
# round-trippable so use repr()
594594
return repr(self.converted)

pandas/core/dtypes/dtypes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ def __eq__(self, other):
393393
return hash(self) == hash(other)
394394

395395
def __repr__(self):
396-
tpl = u'CategoricalDtype(categories={}ordered={})'
396+
tpl = 'CategoricalDtype(categories={}ordered={})'
397397
if self.categories is None:
398-
data = u"None, "
398+
data = "None, "
399399
else:
400400
data = self.categories._format_data(name=self.__class__.__name__)
401401
return tpl.format(data, self.ordered)

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8063,4 +8063,4 @@ def _from_nested_dict(data):
80638063

80648064

80658065
def _put_str(s, space):
8066-
return u'{s}'.format(s=s)[:space].ljust(space)
8066+
return '{s}'.format(s=s)[:space].ljust(space)

pandas/core/indexes/multi.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ def from_tuples(cls, tuples, sortorder=None, names=None):
379379
380380
Examples
381381
--------
382-
>>> tuples = [(1, u'red'), (1, u'blue'),
383-
... (2, u'red'), (2, u'blue')]
382+
>>> tuples = [(1, 'red'), (1, 'blue'),
383+
... (2, 'red'), (2, 'blue')]
384384
>>> pd.MultiIndex.from_tuples(tuples, names=('number', 'color'))
385385
MultiIndex(levels=[[1, 2], ['blue', 'red']],
386386
codes=[[0, 0, 1, 1], [1, 0, 1, 0]],
@@ -621,25 +621,25 @@ def set_levels(self, levels, level=None, inplace=False,
621621
622622
Examples
623623
--------
624-
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
625-
(2, u'one'), (2, u'two')],
624+
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
625+
(2, 'one'), (2, 'two')],
626626
names=['foo', 'bar'])
627627
>>> idx.set_levels([['a','b'], [1,2]])
628-
MultiIndex(levels=[[u'a', u'b'], [1, 2]],
628+
MultiIndex(levels=[['a', 'b'], [1, 2]],
629629
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
630-
names=[u'foo', u'bar'])
630+
names=['foo', 'bar'])
631631
>>> idx.set_levels(['a','b'], level=0)
632-
MultiIndex(levels=[[u'a', u'b'], [u'one', u'two']],
632+
MultiIndex(levels=[['a', 'b'], ['one', 'two']],
633633
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
634-
names=[u'foo', u'bar'])
634+
names=['foo', 'bar'])
635635
>>> idx.set_levels(['a','b'], level='bar')
636-
MultiIndex(levels=[[1, 2], [u'a', u'b']],
636+
MultiIndex(levels=[[1, 2], ['a', 'b']],
637637
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
638-
names=[u'foo', u'bar'])
638+
names=['foo', 'bar'])
639639
>>> idx.set_levels([['a','b'], [1,2]], level=[0,1])
640-
MultiIndex(levels=[[u'a', u'b'], [1, 2]],
640+
MultiIndex(levels=[['a', 'b'], [1, 2]],
641641
codes=[[0, 0, 1, 1], [0, 1, 0, 1]],
642-
names=[u'foo', u'bar'])
642+
names=['foo', 'bar'])
643643
"""
644644
if is_list_like(levels) and not isinstance(levels, Index):
645645
levels = list(levels)
@@ -740,25 +740,25 @@ def set_codes(self, codes, level=None, inplace=False,
740740
741741
Examples
742742
--------
743-
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
744-
(2, u'one'), (2, u'two')],
743+
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
744+
(2, 'one'), (2, 'two')],
745745
names=['foo', 'bar'])
746746
>>> idx.set_codes([[1,0,1,0], [0,0,1,1]])
747-
MultiIndex(levels=[[1, 2], [u'one', u'two']],
747+
MultiIndex(levels=[[1, 2], ['one', 'two']],
748748
codes=[[1, 0, 1, 0], [0, 0, 1, 1]],
749-
names=[u'foo', u'bar'])
749+
names=['foo', 'bar'])
750750
>>> idx.set_codes([1,0,1,0], level=0)
751-
MultiIndex(levels=[[1, 2], [u'one', u'two']],
751+
MultiIndex(levels=[[1, 2], ['one', 'two']],
752752
codes=[[1, 0, 1, 0], [0, 1, 0, 1]],
753-
names=[u'foo', u'bar'])
753+
names=['foo', 'bar'])
754754
>>> idx.set_codes([0,0,1,1], level='bar')
755-
MultiIndex(levels=[[1, 2], [u'one', u'two']],
755+
MultiIndex(levels=[[1, 2], ['one', 'two']],
756756
codes=[[0, 0, 1, 1], [0, 0, 1, 1]],
757-
names=[u'foo', u'bar'])
757+
names=['foo', 'bar'])
758758
>>> idx.set_codes([[1,0,1,0], [0,0,1,1]], level=[0,1])
759-
MultiIndex(levels=[[1, 2], [u'one', u'two']],
759+
MultiIndex(levels=[[1, 2], ['one', 'two']],
760760
codes=[[1, 0, 1, 0], [0, 0, 1, 1]],
761-
names=[u'foo', u'bar'])
761+
names=['foo', 'bar'])
762762
"""
763763
if level is not None and not is_list_like(level):
764764
if not is_list_like(codes):
@@ -1512,10 +1512,10 @@ def to_hierarchical(self, n_repeat, n_shuffle=1):
15121512
15131513
Examples
15141514
--------
1515-
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
1516-
(2, u'one'), (2, u'two')])
1515+
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
1516+
(2, 'one'), (2, 'two')])
15171517
>>> idx.to_hierarchical(3)
1518-
MultiIndex(levels=[[1, 2], [u'one', u'two']],
1518+
MultiIndex(levels=[[1, 2], ['one', 'two']],
15191519
codes=[[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
15201520
[0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]])
15211521
"""

pandas/core/indexes/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def _maybe_convert_timedelta(self, other):
400400
# ------------------------------------------------------------------------
401401
# Rendering Methods
402402

403-
def _format_native_types(self, na_rep=u'NaT', quoting=None, **kwargs):
403+
def _format_native_types(self, na_rep='NaT', quoting=None, **kwargs):
404404
# just dispatch, return ndarray
405405
return self._data._format_native_types(na_rep=na_rep,
406406
quoting=quoting,

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ def _validate_read_indexer(self, key, indexer, axis, raise_missing=False):
12421242
if missing:
12431243
if missing == len(indexer):
12441244
raise KeyError(
1245-
u"None of [{key}] are in the [{axis}]".format(
1245+
"None of [{key}] are in the [{axis}]".format(
12461246
key=key, axis=self.obj._get_axis_name(axis)))
12471247

12481248
# We (temporarily) allow for some missing keys with .loc, except in

pandas/core/internals/managers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ def __unicode__(self):
296296
output = pprint_thing(self.__class__.__name__)
297297
for i, ax in enumerate(self.axes):
298298
if i == 0:
299-
output += u'\nItems: {ax}'.format(ax=ax)
299+
output += '\nItems: {ax}'.format(ax=ax)
300300
else:
301-
output += u'\nAxis {i}: {ax}'.format(i=i, ax=ax)
301+
output += '\nAxis {i}: {ax}'.format(i=i, ax=ax)
302302

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

307307
def _verify_integrity(self):

pandas/core/reshape/pivot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _add_margins(table, data, values, rows, cols, aggfunc,
154154
if not isinstance(margins_name, compat.string_types):
155155
raise ValueError('margins_name argument must be a string')
156156

157-
msg = u'Conflicting name "{name}" in margins'.format(name=margins_name)
157+
msg = 'Conflicting name "{name}" in margins'.format(name=margins_name)
158158
for level in table.index.names:
159159
if margins_name in table.index.get_level_values(level):
160160
raise ValueError(msg)

pandas/errors/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ParserWarning(Warning):
138138
Using a `sep` in `pd.read_csv` other than a single character:
139139
140140
>>> import io
141-
>>> csv = u'''a;b;c
141+
>>> csv = '''a;b;c
142142
... 1;1,8
143143
... 1;2,1'''
144144
>>> df = pd.read_csv(io.StringIO(csv), sep='[;,]') # doctest: +SKIP

pandas/io/formats/format.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def _get_footer(self):
213213

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

219219
if (self.length is True or
@@ -227,7 +227,7 @@ def _get_footer(self):
227227
if name:
228228
if footer:
229229
footer += ', '
230-
footer += u'dtype: {typ}'.format(typ=pprint_thing(name))
230+
footer += 'dtype: {typ}'.format(typ=pprint_thing(name))
231231

232232
# level infos are added to the end and in a new line, like it is done
233233
# for Categoricals
@@ -949,10 +949,10 @@ def _format(x):
949949
return 'NaT'
950950
return self.na_rep
951951
elif isinstance(x, PandasObject):
952-
return u'{x}'.format(x=x)
952+
return '{x}'.format(x=x)
953953
else:
954954
# object dtype
955-
return u'{x}'.format(x=formatter(x))
955+
return '{x}'.format(x=formatter(x))
956956

957957
vals = self.values
958958
if isinstance(vals, Index):
@@ -968,16 +968,16 @@ def _format(x):
968968
fmt_values = []
969969
for i, v in enumerate(vals):
970970
if not is_float_type[i] and leading_space:
971-
fmt_values.append(u' {v}'.format(v=_format(v)))
971+
fmt_values.append(' {v}'.format(v=_format(v)))
972972
elif is_float_type[i]:
973973
fmt_values.append(float_format(v))
974974
else:
975975
if leading_space is False:
976976
# False specifically, so that the default is
977977
# to include a space if we get here.
978-
tpl = u'{v}'
978+
tpl = '{v}'
979979
else:
980-
tpl = u' {v}'
980+
tpl = ' {v}'
981981
fmt_values.append(tpl.format(v=_format(v)))
982982

983983
return fmt_values

pandas/io/formats/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _write_cell(self, s, kind='td', indent=0, tags=None):
118118
else:
119119
end_a = ''
120120

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

124124
def write_tr(self, line, indent=0, indent_delta=0, header=False,

pandas/io/formats/printing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,17 @@ def best_len(values):
336336
else:
337337
return 0
338338

339-
close = u', '
339+
close = ', '
340340

341341
if n == 0:
342-
summary = u'[]{}'.format(close)
342+
summary = '[]{}'.format(close)
343343
elif n == 1:
344344
first = formatter(obj[0])
345-
summary = u'[{}]{}'.format(first, close)
345+
summary = '[{}]{}'.format(first, close)
346346
elif n == 2:
347347
first = formatter(obj[0])
348348
last = formatter(obj[-1])
349-
summary = u'[{}, {}]{}'.format(first, last, close)
349+
summary = '[{}, {}]{}'.format(first, last, close)
350350
else:
351351

352352
if n > max_seq_items:

0 commit comments

Comments
 (0)