price.resample('M').count().plot(title='Monthly Counts')
W : weekly frequency
M : month end frequency
SM : semi-month end frequency (15th and end of month)
Q : quarter end frequency
price.resample('M').count().plot(title='Monthly Counts')
W : weekly frequency
M : month end frequency
SM : semi-month end frequency (15th and end of month)
Q : quarter end frequency
import random
mylist = [1, 2, 3]
random.shuffle(mylist) # randomly change the order of the list
print(mylist)
print(random.choice(mylist)) # randomly choose one element from the list
guofyuan @ htpvis-025a$ cat test.txt
AAA 111 123
BBB 222 234
CCC 333 345
guofyuan @ htpvis-025a$ awk '{if(maxc<NF)maxc=NF; for(i=1;i<=NF;i++){(a[i]!=""?a[i]=a[i]RS$i:a[i]=$i)} } END{for(i=1;i<=maxc;i++)print a[i]}' test.txt
AAA
BBB
CCC
111
222
333
123
234
345
gawk '{for (i=1; i<=NF; i++) # loop over columns
data[i][NR]=$i # store in data[column][line]
}
END {for (i=1;i<=NR;i++) # loop over lines
for (j=1;j<=NF;j++) # loop over columns
print data[i][j] # print the given field
}' file
https://stackoverflow.com/questions/39287224/how-to-print-columns-one-after-the-other-in-bash
$ cat TBB11-str-ghost-far-tmp.txt | awk '{for(i=1;i<=NF;i++) {print $i}}'
Input
guofyuan @ htpvis-025a$ head TBB11-str-ghost-far-tmp.txt
0.000 0.000 0.000 0.000 0.000 0.000 -0.001
0.001 -0.001 -0.002 0.007 -0.013 0.016 -0.012
-0.006 0.038 -0.076 0.100 -0.087 0.014 0.118
-0.278 0.401 -0.403 0.213 0.193 -0.762 1.365
-1.808 1.865 -1.235 -0.757 50.286 57.557 5.330
5.619 -27.954 -110.350 -86.889 -19.798 -6.313 21.974
52.920 32.938 6.974 1.216 2.681 6.191 4.807
2.697 1.438 -0.089 0.905 1.381 0.864 0.263
0.096 0.493 0.419 0.371 0.348 0.237 0.287
0.396 0.447 0.389 0.383 0.459 0.519 0.553
output
guofyuan @ htpvis-025a$ head TBB11-str-ghost-far-vertical.txt
0.000
0.000
0.000
0.000
0.000
0.000
-0.001
0.001
-0.001
-0.002
guofyuan @ htpvis-025a$ ls Seq* | nl | sed 's/_Subline_/ /g' | sed 's/Seq//g' | awk '{print $2'} | uniq -c | awk '$1<4'
3 125
Imageio
To select a 2D frame, pick a frame for the first axis and select all data
from the remaining two: vol[0, :, :]
For this exercise, use for loop to plot every 40th slice of vol on a
separate subplot. matplotlib.pyplot (as plt) has been imported for you.
testEqual compares what is returned by the distance function
and the 0 (the correct answer).
import test
def distance(x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
dsquared = dx**2 + dy**2
result = dsquared**0.5
return result
test.testEqual(distance(1,2, 1,2), 0)
test.testEqual(distance(1,2, 4,6), 5)
test.testEqual(distance(0,0, 1,1), 1.41421)
Pass
Pass
Pass
For even numbers we want to start at 0
and count by 2’s. So if we wanted the first 10 even numbers we would use
range(0,19,2). The most general form of the range is
range(start, beyondLast, step).
print(list(range(0, 20, 2)))
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
Not printing 20 as you would thought
Therandrangefunction generates an integer between its lower and upper argument, using the same semantics asrange— so the lower bound is included, but the upper bound is excluded.
diceThrow = random.randrange(1, 7)
# return an int, one of 1,2,3,4,5,6 But not 7
Division and Reminder
total_secs=7350
hours=total_secs//3600 # hours=2
secs_still_remaining=total_secs%3600 # secs_still_remaining=150
minutes= secs_still_remaining // 60 # minutes=2
secs_finally_remaining=secs_still_remaining %60 # seconds=30
$ xrandr
$ xrandr --newmode
"2560x1440_60.00" 312.25 2560 2752 3024 3488 1440
1443 1448 1493 -hsync +vsync
$ xrandr --addmode VNC-0 "2560x1440_60.00"
https://superuser.com/questions/223240/changing-screen-resolution-in-centos