in my CSV file, each line contains timeStamp and some values that I want to display as separated flot charts.
Flot expects array of pairs as [timeStamp , value]
but I have arra of struct [timeStamp, val1,val2, val3]
Is there a simple solution to use such struct in Flot?
or that I must duplicate my timeStamp for each csv.column ? e.g. [time,val1], [time,val2] . . .
similiar question, with no answer - Plotting multiple datasets in Flot from a multidimensional array
Related
I have a geodataframe ("timezones") that contains the timezone labels of all the world (for example: "Europe/Zurich", or "Pacific/Galapagos") and its corresponding geometry:
On the other hand, I have a geodataframe ("regions") with ~80K rows, where each row represents a region in some country, defined by a certain geometry (a Polygon or Multipolygon):
I need to assign a timezone to each of the regions, so the final dataframe has "region", "province", "geometry" and "timezone" columns.
I don't know how to do it, maybe using a for loop over each row and check if geometry is inside the timezone using geopandas within or contains?
for i,row in regions.iterrows():
if regions.geometry.within(timezones.geometry)=="True":
region['timezone'] = timezones['timezone']
This example does not work, but it could be something similar to this? Or maybe there is a better way to do it?
Any suggestions would be highly appreciated.
I'm extracting data from JSON and mapping two arrays in presto.It works fine when there are no repeated values in the array but fails with error - Duplicate map keys are not allowed if any of the values are repeated.I need those values and cannot remove any of the values from the array.Is there a work around for this scenario?
Sample values:
array1 -- [Rewards,NEW,Rewards,NEW]
array2 -- [losg1,losg2,losg3,losg4]
Map key/value has to be generated like this [Rewards=>losg1,NEW=>losg2,Rewards=>losg3,NEW=>losg4]
Pairs of associations can be returned like this:
SELECT ARRAY[ROW('Rewards', 'losg1'), ROW('NEW', 'losg2'), ROW('Rewards', 'losg3')]
I have the following csv file:
id,label
1000,8
1001,1
1002,8
1003,1
1004,6
1005,1
1006,1
1007,2
I also have an image dataset which contains files like this:
1000_c.jpg
1000_v.jpg
1001_c.jpg
1001_v.jpg
and so on. For each observation I've got 2 images. I created an ndarray with the vertically stacked images so they become one image per observation instead of 2. My array has shape (1976, 15104).
I want to create an array that contains the label value corresponging to each vstacked image. The resulting array should of shape (1976, 2) one column for the id and another for the label. How can I do that?
I'm selecting some Strings from my SQLite DB and store them in an Array. Now I want to plot the values with the framework "Razorflow". I think it is only possible if the values of the array are floats, am I wrong?
In my DB I'm storing temperature and humidity of 12 different sensor nodes, in this form:
id|temperature|humidity|...|...
1 | 22.50C| 47.50%|...|...
..
I heared something about the floatval()-function, I also heared that this function is not made for objects like Arrays. Is there a simple solution? I'm very new to PHP :-D
Depends on how you're getting the values back from the database.
id|temperature|humidity|...|...
Sounds like a string to me, so i would first explode it into an array and then iterate the array casting floatval into every element.
What you do after that process depends on you.
EDIT:
If your query is:
$humi = $database->query((SELECT humidity FROM Measurement WHERE topic_hum='WSN9/humi'
You will get back only 1 column (humidity) and 0 or more rows depending on your database. Let's say it's only 1 for now:
$resul = mysql_query($humi,$link);
$rows = mysql_fetch_array($resul);
$myarray = explode("|", $rows["humidity"]);
This should give us an array called myarray containing X elements each with a "single" string part value. So we can iterate over it and parse it. There is also the shorthand "array_map" to iterate over an array using a callback function over each element and returning the value as an array:
$myparsedarray = array_map('floatval', $myarray)
Now you have an array with only float values (and errors maybe, check your data!)
I want to create a static chart of values pulled out of a MySQL database.
The chart format would be (x axis : dd/mm/yy hh:mm:ss (corresponding to timestamp of mysql database)) and y-axis would be a double value. I am able to successfully retrieve these values from MySql database.I want help plotting them by ZingChart
Nikita.
Once you've retrieved your values from your MySQL database, you'll want to convert the MySQL date values in to Unix time in milliseconds. I've populated a $date array with the MySQL date values, and iterated over the array, calling strtotime to first convert to Unix time, and multiplying by 1000 to convert to milliseconds. In order to be able to directly modify array elements within the loop, I've also preceded $value with to assign by reference.
foreach ($date as &$value){
$value = strtotime( $value ) * 1000;
}
So now that the values in the $date array have been converted to the proper format, it's time to create a JavaScript array from the PHP array. This can be done using join():
var dateValues = [<?php echo join($date, ',') ?>];
The resulting array looks like this:
var dateValues = [1356994800000,1357081200000,1357167600000, ... ];
To use this array in ZingChart, use the dateValues variable with "values" in the scale-x object. To convert the Unix time values back to dates in ZingChart, add the "transform" object, and set it to "type":"date".
"scale-x":{
"values": dateValues,
"transform":{
"type":"date",
"item":{
"visible":false
}
}
},
...
That takes care of the scale. To get your other values in the chart, you do pretty much the same thing. Convert the PHP arrays into JavaScript arrays, and use the array variable in your chart JSON.
With the PHP $series array:
var seriesValues = [<?php echo join($series, ',') ?>];
In your chart JSON:
"series":[
{
"values":seriesValues
}
]
I've compiled all of this in to a Github Gist for you. Let me know if you have any questions!
Check out our demos repo on GitHub. We have a tutorial specifically about connecting to a MySQL database with PHP.
There's a step-by-step walkthrough on our site, too.
If you share your JSON or more details about it, I can help you with putting your chart together.
I'm on the ZingChart team. Please let me know if you have other questions.