Skip to content

Commit cf4a924

Browse files
committed
Example for String type is added
1 parent 26a0dc8 commit cf4a924

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

contrib/numpy/datatypes.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ The `datetime64()` is used to define the date, month and year.
166166
```
167167

168168
## Example for string type
169+
``` python
170+
import numpy as np
171+
172+
arr = np.str_("roopa")
173+
174+
print(arr.dtype)
175+
176+
# Output: <U5
177+
```
169178

170179
## Example for object type
171180
``` python
@@ -181,7 +190,15 @@ The `datetime64()` is used to define the date, month and year.
181190
# object
182191
```
183192
## Example for unicode string type
193+
``` python
194+
import numpy as np
195+
196+
arr = np.array(['apple', 'banana', 'cherry'])
197+
198+
print(arr.dtype)
184199

200+
# Output: <U6
201+
```
185202
## Example for timedelta type
186203
The `timedelta64()` used to find the difference between the `datetime64()`. The arguments for timedelta64 are a number, to represent the number of units, and a date/time unit, such as (D)ay, (M)onth, (Y)ear, (h)ours, (m)inutes, or (s)econds. The timedelta64 data type also accepts the string “NAT” in place of the number for a “Not A Time” value.
187204

@@ -199,5 +216,4 @@ The `timedelta64()` used to find the difference between the `datetime64()`. The
199216
# 366 days
200217
# timedelta64[D]
201218
```
202-
# Data Type Conversion
203-
219+
# Data Type Conversion

0 commit comments

Comments
 (0)