other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
other:python:misc_by_jyp [2022/03/08 17:40] – Added a string section jypeter | other:python:misc_by_jyp [2022/05/23 17:36] – [numpy related stuff] Added the "variable number of indices" section jypeter | ||
---|---|---|---|
Line 41: | Line 41: | ||
==== Playing with strings ==== | ==== Playing with strings ==== | ||
- | === Filenames, etc === | + | === Filenames, etc... === |
Check [[other: | Check [[other: | ||
Line 247: | Line 247: | ||
==== numpy related stuff ==== | ==== numpy related stuff ==== | ||
+ | |||
+ | === Dealing with a variable number of indices === | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | < | ||
+ | >>> | ||
+ | array([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | ||
+ | [0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], | ||
+ | ... | ||
+ | [0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]) | ||
+ | >>> | ||
+ | (10, 10) | ||
+ | |||
+ | >>> | ||
+ | array([[0., 0.], | ||
+ | [1., 0.], | ||
+ | [0., 1.], | ||
+ | [0., 0.]]) | ||
+ | |||
+ | >>> | ||
+ | >>> | ||
+ | >>> | ||
+ | array([[0., 0.], | ||
+ | [1., 0.], | ||
+ | [0., 1.], | ||
+ | [0., 0.]]) | ||
+ | |||
+ | >>> | ||
+ | >>> | ||
+ | array([[0., 0.], | ||
+ | [1., 0.], | ||
+ | [0., 1.], | ||
+ | [0., 0.]]) | ||
+ | |||
+ | >>> | ||
+ | >>> | ||
+ | array([[0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], | ||
+ | [0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], | ||
+ | [0., 0., 0., 0., 0., 1., 0., 0., 0., 0.], | ||
+ | [0., 0., 0., 0., 0., 0., 1., 0., 0., 0.]]) | ||
+ | >>> | ||
+ | (4, 10) | ||
+ | |||
+ | >>> | ||
+ | >>> | ||
+ | >>> | ||
+ | array([[ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | ||
+ | [ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.], | ||
+ | [ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.], | ||
+ | [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], | ||
+ | [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], | ||
+ | [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], | ||
+ | [-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], | ||
+ | [ 0., 0., 0., 0., 0., 0., 0., 1., 0., 0.], | ||
+ | [ 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.], | ||
+ | [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]) | ||
+ | </ | ||
=== Finding and counting unique values === | === Finding and counting unique values === |
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter