@@ -1231,6 +1231,7 @@ def to_records(self, index=True, convert_datetime64=True):
1231
1231
1232
1232
Examples
1233
1233
--------
1234
+
1234
1235
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.5, 0.75]}, index=['a', 'b'])
1235
1236
>>> df
1236
1237
col1 col2
@@ -1241,11 +1242,13 @@ def to_records(self, index=True, convert_datetime64=True):
1241
1242
dtype=[('index', 'O'), ('col1', '<i8'), ('col2', '<f8')])
1242
1243
1243
1244
The index can be excluded from the record array:
1245
+
1244
1246
>>> df.to_records(index=False)
1245
1247
rec.array([(1, 0.5 ), (2, 0.75)],
1246
1248
dtype=[('col1', '<i8'), ('col2', '<f8')])
1247
1249
1248
- By default, timestamps are converted to `datetime.datetime` objects
1250
+ By default, timestamps are converted to `datetime.datetime` objects:
1251
+
1249
1252
>>> df.index = pd.date_range('2018-01-01 09:00', periods=2, freq='min')
1250
1253
>>> df
1251
1254
col1 col2
@@ -1257,6 +1260,7 @@ def to_records(self, index=True, convert_datetime64=True):
1257
1260
dtype=[('index', 'O'), ('col1', '<i8'), ('col2', '<f8')])
1258
1261
1259
1262
The timestamp conversion can be disabled to use NumPy datetime64 objects instead:
1263
+
1260
1264
>>> df.to_records(convert_datetime64=False)
1261
1265
rec.array([('2018-01-01T09:00:00.000000000', 1, 0.5 ),
1262
1266
('2018-01-01T09:01:00.000000000', 2, 0.75)],
0 commit comments