Skip to content

Commit e7b4cf2

Browse files
flake8 errors
1 parent b03dda7 commit e7b4cf2

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

pandas/core/frame.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,8 @@ def to_records(self, index=True, convert_datetime64=True):
12111211
"""
12121212
Convert DataFrame to record array.
12131213
1214-
Index will be put in the 'index' field of the record array if requested.
1214+
Index will be put in the 'index' field of the record array if
1215+
requested.
12151216
12161217
Parameters
12171218
----------
@@ -1227,44 +1228,50 @@ def to_records(self, index=True, convert_datetime64=True):
12271228
12281229
See Also
12291230
--------
1230-
DataFrame.from_records: convert structured or record ndarray to DataFrame.
1231+
DataFrame.from_records: convert structured or record ndarray
1232+
to DataFrame.
1233+
numpy.recarray: ndarray that allows field access using
1234+
attributes, analogous to typed (typed) columns in a
1235+
spreadsheet.
12311236
12321237
Examples
12331238
--------
12341239
1235-
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.5, 0.75]}, index=['a', 'b'])
1240+
>>> df = pd.DataFrame({'A': [1, 2], 'B': [0.5, 0.75]},
1241+
... index=['a', 'b'])
12361242
>>> df
1237-
col1 col2
1243+
A B
12381244
a 1 0.50
12391245
b 2 0.75
12401246
>>> df.to_records()
12411247
rec.array([('a', 1, 0.5 ), ('b', 2, 0.75)],
1242-
dtype=[('index', 'O'), ('col1', '<i8'), ('col2', '<f8')])
1248+
dtype=[('index', 'O'), ('A', '<i8'), ('B', '<f8')])
12431249
12441250
The index can be excluded from the record array:
12451251
12461252
>>> df.to_records(index=False)
12471253
rec.array([(1, 0.5 ), (2, 0.75)],
1248-
dtype=[('col1', '<i8'), ('col2', '<f8')])
1254+
dtype=[('A', '<i8'), ('B', '<f8')])
12491255
12501256
By default, timestamps are converted to `datetime.datetime`:
12511257
12521258
>>> df.index = pd.date_range('2018-01-01 09:00', periods=2, freq='min')
12531259
>>> df
1254-
col1 col2
1260+
A B
12551261
2018-01-01 09:00:00 1 0.50
12561262
2018-01-01 09:01:00 2 0.75
12571263
>>> df.to_records()
12581264
rec.array([(datetime.datetime(2018, 1, 1, 9, 0), 1, 0.5 ),
12591265
(datetime.datetime(2018, 1, 1, 9, 1), 2, 0.75)],
1260-
dtype=[('index', 'O'), ('col1', '<i8'), ('col2', '<f8')])
1266+
dtype=[('index', 'O'), ('A', '<i8'), ('B', '<f8')])
12611267
1262-
The timestamp conversion can be disabled so NumPy's datetime64 data type is used instead:
1268+
The timestamp conversion can be disabled so NumPy's datetime64
1269+
data type is used instead:
12631270
12641271
>>> df.to_records(convert_datetime64=False)
12651272
rec.array([('2018-01-01T09:00:00.000000000', 1, 0.5 ),
12661273
('2018-01-01T09:01:00.000000000', 2, 0.75)],
1267-
dtype=[('index', '<M8[ns]'), ('col1', '<i8'), ('col2', '<f8')])
1274+
dtype=[('index', '<M8[ns]'), ('A', '<i8'), ('B', '<f8')])
12681275
"""
12691276
if index:
12701277
if is_datetime64_any_dtype(self.index) and convert_datetime64:

0 commit comments

Comments
 (0)