You probably want to replace
if __name__ == "__main__":
This second form means only run the indented code if this module specifically is called, not if it is imported. I'm assuming after the provided code, you just call main(), which is fine, but if you have no intentions of using main outside of this module, you should use the ...
I have considered first column as DatetimeIndex looking at the provided data where dates does not have a column name.
As I worked more with these data, I realized that two problems were keeping me away from a decent performance:
There is a big overhead with using pandas, and
The data about visits is sparse, and I should make use of it
So, the same data can be calculated by starting with an np.zeros matrix of a corresponding size, and setting 1s within the range of each ...
I think it is slow because your periods_breakdown is gigantic, and to fill each cell you have to compute its value.
But what you compute is whether each individual visit overlapped with each other visit, which is overkill.
If what you want is to know when there is two visits (or more) overlapping, but don't need to know which specific ones, you can simply ...
Inspired by Gulzar at Stackoverflow.
I do not realize it works until after a night's sleep.
So, below is enough:
offset_orig = range(m)
offset_train, offset_test = train_test_split(offset_orig, train_size=0.7, random_state=666)
x_train = x.iloc[offset_train] # later
x_test = x.iloc[offset_test]
The offset_train list ([0, 2, ...]) has the same feature in ...
You need to drop your use of geopy. So far as I can see it does not support vectorised inverse geodesics. Instead use cartopy which inherently supports this.
The following example code uses random instead of real data, but with the same size as your real data, and completes in about one second. distances and close are both matrices whose rows correspond to ...