Kolmogorov-Smirnov test returning a p-value of 1 I have two datasets data1 and data2 with different sample sizes: over 50,000 and around 8,000, respectively. These data consist of positive integer values varying from 1 to 50.
(Due to the size of the data, I cannot upload the entire set. Instead, I upload the histogram of these datasets.)

(The histogram below shows the normalized version with log applied to count.)

My objective is to see whether there exists any statistically significant difference between the cumulative distributions of these two dataset values. Hence, I performed a 2-sample KS test via Python (using ks_2samp from scipy.stats package).
I have performed three tests in total with different null hypotheses:

*

*$H_0^1:\ \text{data1} \neq \text{data2}$


*$H_0^2:\ \text{data1} > \text{data2}$


*$H_0^3:\ \text{data1} < \text{data2}$
The resulting p-values are respectively: 3.448839769104661e-105, 1.0, and 1.5636837258561576e-105. Not only the first and the last values are infinitesimal, but I find the second value the most absurd, as p-value being 1.0 seems infeasible.
Assuming that the execution in Python isn't incorrect, I'm wondering whether applying KS test in this case is inappropriate. However, I've done some research including Cross Validated, and it seems appropriate to do so.
Is KS test a correct test to achieve my objective? If not, what would be an adequate alternative? If so, what could I be doing wrong?
(I have asked a similar question in Stack Overflow: ks_2samp returns p-value of 1.0. However, here I am asking for a mathematical explanation regarding KS test rather than a code fix.)
 A: Edit: Corrected my initial response after reading more about the one-sided KS-test.
Note that your null hypotheses are written down wrongly, as these are about the underlying true distribution functions, not about the observed data. Also these look like the alternatives rather than the null hypothesis, which should be cdf1=cdf2 for all three tests.
The sample size is quite large, so the KS-test can clearly see that the two distributions are different. Furthermore it can clearly see that data1 tends to have larger values, so the first distribution seems to be stochastically larger than the second. Note that p-values are computed assuming the null hypothesis. The first p-value is essentially zero, meaning that it's crystal clear that the two underlying distributions are not equal. In fact it is crystal clear that the first distribution tends to produce larger values, as the third p-value shows, which is also essentially zero. The third p-value comes from looking at the negative differences between the two empirical cdfs (the first cdf will be uniformly smaller than the second if the first distribution is stochastically larger). The second p-value looks at positive differences. From looking at the histograms I'd think that indeed the first empirical cdf is uniformly smaller than the second one (i.e., the distribution stochastically larger), so there will be a maximum positive difference of zero, the smallest possible. This should give $p=1$ (there may be a tiny difference but that will still amount to 1.0 rounded as 1 is the leading digit so 1 minus something extremely small will be rounded to 1.0). So this is all correct.
