Posts

python - Replace Numpy NaN with string in list with strings -

i have list containing string elements, , several nan numpy floats. e.g. l=['foo', 'bar', 'baz', 'nan'] how replace float nan string missing ? most answers found regard issue in pandas dataframe. try 1: for x in l: x=x.replace('nan', 'missing') gives attributeerror: 'float' object has no attribute 'replace' try 2: for x in l: if str(x)=='nan': x=str(x) command executes, nothing changes. advised comments: ['missing' if x 'nan' else x x in l] ['missing' if x np.isnan else x x in l] ['missing' if x np.nan else x x in l] commands execute, nothing changes. i think have bad format nan's (notice nan outputed nan , not 'nan'). answers comment should work: >>> import numpy np >>> l=['foo', 'bar', 'baz', np.nan] >>> print l ['foo', 'bar', 'baz', nan]...

couchbase - N1QL: Using select directly on arrays -

i having problems on querying objects inside array. i have sample document { ... status: 'active', current: { ... }, history: [ { id: '73bae187-1101-4fb3-a71a-2bbf90026eb3', date: '2017-03-28t09:32:22.884z', content: 'this second content' }, { id: 'd6a6c63d-42db-4ef5-88e9-616cfe539a57', date: '2017-03-25t09:32:22.884z', content: 'this first content' }, { id: '3fbdb846-2b55-4ff8-8960-86997ef31556', schedule: '1970-01-01t00:00:00.000z', content: 'this old content' } ] } i want directly query history array sub document in want apply date filters. is possible in n1ql retrieve history array contain objects satisfies condition? can apply limit can control number of the returned objects inside array? i tried queries using splicing [0:$1] limit input doesn't work when limit greater array size. thanks hel...

Odata trying to find out how it works -

i read odata still confusing me, me understand this? my question is: how can "buy" , manage? what need use? found test url's can example have on local computer ms sql server , access db odata in web app? thank tou

java - Hibernate: How to Map Composite Keys? -

i have table 3 composite keys. custom_id , patient_idpatient , service_provider_type_idservice_provider_type . current mapping below <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="beans.serviceprovider" table="service_provider" catalog="myglukose" optimistic-lock="version"> <id name="customid" type="string"> <column name="custom_id" not-null="true"/> </id> <many-to-one name="patient" class="beans.patient" fetch="select"> <column name="patient_idpatient" not-null="true"/> </many-to-one> <many-to-one name="serviceprov...

swift - wondering use of computed property -

before. class drawingview: uiview { var arccenter = cgpoint(x: frame.midx, y: frame.midy) // error } after. class drawingview: uiview { var arccenter: cgpoint { return cgpoint(x: frame.midx, y: frame.midy) } } i know why error occur, can't understand why second codes not makes error. the first form not computed property. it stored property default value. it uses self causes error because @ moment default value going assigned instance not guaranteed instantiated. an alternative computed property – computed @ moment it's called – is lazy instantiated property. lazy var arccenter: cgpoint = cgpoint(x: self.frame.midx, y: self.frame.midy) unlike stored property default value assigned when property accessed first time.

python - getting a circular patch on every point on an Active Contour? -

i'm trying implement localized region-based segmentation given shawn-lankton. relies on local statistics of image rather global. so while localizing segmentation using active contours. specifies function b such circular patch around points of active contour. points within circular patch should 1, , exterior 0. how implement such patch , assign 1 inner region? the patch has updated once active contour evovles.

mysql - need a select query? count the number of id's which appear unique time? -

this question has answer here: mysql - count number of unique values 2 answers need select query should count cat_id table [output should 4][1] [1]: https://i.stack.imgur.com/caqmc.png output 4 select count (distinct cat_id) table_name