Comments (3)
I don't know. Can you post an equivalent snippet in Python?
from numpy.net.
@henon Well there's multiple ways. I think this is the most idiomatic:
import numpy as np
datetimes = np.array(
[
'2000-01-15',
'2000-06-15',
'2001-01-15',
'2001-06-15'
],
dtype='datetime64'
)
print(datetimes.dtype)
print(np.diff(datetimes))
You can also do this:
import numpy as np
from datetime import datetime
datetimes = [
np.datetime64('2000-01-15'),
np.datetime64('2000-06-15'),
np.datetime64('2001-01-15'),
np.datetime64('2001-06-15')
]
datetimes = np.array(datetimes)
print(np.diff(datetimes).dtype)
print(np.diff(datetimes))
But if I had to emulate the C# as closely as I could, I guess I was attempting something like this:
import numpy as np
from datetime import datetime
datetimes = [
datetime(2000, 1, 15),
datetime(2000, 6, 15),
datetime(2001, 1, 15),
datetime(2001, 6, 15)
]
datetimes = np.array(datetimes)
print(np.diff(datetimes).dtype)
print(np.diff(datetimes))
So it looks like there's an np.datetime64
type wrapped around datetime
from the standard library. Maybe I shouldn't have been trying to access System.DateTime
? Perhaps there is already an np.datetime64
equivalent in Numpy.NET?
from numpy.net.
If you know how the date times are represented in memory in numpy (i.e. milliseconds since 1970 or whatever, I really don't know) then you can always use this workaround as described in #115 by creating a byte[] that contains the data which represent the datetimes you want. Of course that is a quite inconvenient workaround.
I'll look into it how I can support date time arrays, maybe I'll have to use the same workaround internally anyway.
from numpy.net.
Related Issues (20)
- Cannot slice by passing either a string or a Numpy.Models.Slice as an index. HOT 6
- Slow Conversion for 3D arrays HOT 3
- np.load of np.savez impossible to get values back out? HOT 3
- np.array leaks memory HOT 12
- Numpy hangs on exit since version 3.10.1.29 (last stable 3.7.1.28) HOT 7
- Support for CuPy HOT 1
- Please Sign and assign StrongName for Numpy Nuget package
- np.split HOT 12
- `Half` type arrays HOT 7
- Set conditions as NDArray Type HOT 3
- fft() failed: βindex -2 is out of bounds for axis 0 with size 1β HOT 9
- Problem with passing imaginery numbers HOT 3
- Azure AppService and System.DllNotFoundException: Could not load python311.dll with flags RTLD_NOW | RTLD_GLOBAL: python311.dll: cannot open shared object file: No such file or directory HOT 5
- Could not find platform dependent libraries <exec_prefix> HOT 6
- System.TypeLoadException: Could not load type 'Python.Runtime.PyLong' from assembly 'Python.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5000fea6cba702dd'. HOT 5
- Numpy.Bare build for Python 3.11 HOT 3
- np.sum(NDArray, axis:1) not supported? HOT 5
- Unable to use Numpy.NET from linux environment HOT 1
- Hello, has SciSharp/NumSharp stopped development and maintenance? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numpy.net.