Monday, August 20, 2018

How to display nth-row and last row

I need to display nth rows and last one using pandas. I know that nth-rows could be displayed by using iloc

for example:

data = {"x1": [1,2,3,4,5,6,7,8,9,10], "x2": ["a","b","c","d","e","f","g","h","i","j"]}
df = pd.DataFrame(data=data)
a = df.iloc[::2]
print(a)

will display

   x1 x2
0   1  a
2   3  c
4   5  e
6   7  g
8   9  i

But I need it to be:

   x1 x2
0   1  a
2   3  c
4   5  e
6   7  g
8   9  i
9  10  j

how it could be achieved?

Solved

Use union of indices and select by loc if default RangeIndex:

a = df.loc[df.index[::2].union([df.index[-1]])]
print(a)
   x1 x2
0   1  a
2   3  c
4   5  e
6   7  g
8   9  i
9  10  j

Detail:

print(df.index[::2].union([df.index[-1]]))
Int64Index([0, 2, 4, 6, 8, 9], dtype='int64')

Another more general solution:

data = {"x1": [1,2,3,4,5,6,7,8,9,10], "x2": ["a","b","c","d","e","f","g","h","i","j"]}
df = pd.DataFrame(data=data, index=[0]*10)
print (df)
   x1 x2
0   1  a
0   2  b
0   3  c
0   4  d
0   5  e
0   6  f
0   7  g
0   8  h
0   9  i
0  10  j

arr = np.arange(len(df.index))
a = df.iloc[np.union1d(arr[::2], [arr[-1]])]
print(a)
   x1 x2
0   1  a
0   3  c
0   5  e
0   7  g
0   9  i
0  10  j

Sunday, August 19, 2018

How to disable Photoswipe Animation for Thumbnails

I do have square thumbnails and due to the animation on clicking on thumbnails the large images are not shown properly because they are stretched.

So I would like to disable the zoom-animation for thumbnails.

How do I have to set these settings?

Thank you

Solved

I think it's this option:

allowUserZoom = false

Saturday, August 18, 2018

Compile and deploy ruby on VSTS

Can't get ruby sample web application in Visual Studio to work on Azure Cloud https://www.visualstudio.com/en-us/docs/git/gitquickstart. Push to visual studio team services (VSTS) git. The code to be compiled by ci build provided by VSTS, this is allocated randomly by vsts on azure cloud. And once compilation done the deployment should happen the same azure Linux vm which I'd mention in the question.

Environment: Ubuntu 16, ruby 2.2.5, rails 5.

Now I want to build it using hosted build agent through SSH task for build and deployment.

Solved

I had the same issue, just use the BASH for this, don't use the GUI on the portal and you'll do just fine; Some trigger is not activating in the back in order for the service to start;