qid
int64
46k
74.7M
question
stringlengths
54
37.8k
date
stringlengths
10
10
metadata
listlengths
3
3
response_j
stringlengths
17
26k
response_k
stringlengths
26
26k
36,911,421
If a class contains two constructors that take in different types of arguments as shown here: ``` public class Planet { public double xxPos; //its current x position public double yyPos; //its current y position public double xxVel; //its current veolicity in the x direction public double yyVel; //its curr...
2016/04/28
[ "https://Stackoverflow.com/questions/36911421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5249753/" ]
> > 1) How does another class with a main that calls this class determine > which constructor to use? > > > Compiler follows same process as overloaded method for static binding by checking unique method signature. To know about method signature [see this](https://docs.oracle.com/javase/tutorial/java/javaOO/metho...
The constructor to use will be determined based on the number and type of arguments you will pass to it. In Java, the constructor and method signatures (identities) are comprised of the method name (not applicable for constructors, obviously), and the number and type of its parameters. Two methods (or constructors) ...
27,849,023
**HTML** -------- This is a form that accepts a user's input (url): ``` <form method="post" action="/" accept-charset="utf-8"> <input type="search" name="url" placeholder="Enter a url" /> <button>Go</button> </form> ``` **PHP (Laravel)** ----------------- This controller stores the value of the user's inpu...
2015/01/08
[ "https://Stackoverflow.com/questions/27849023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2097870/" ]
You can return a an array, but be sure that elements don't contain the delimiter. Like `print(','.join(name, test))`. Or you can encode to json like `json.dumps([name, test])`, then parse json in PHP. Second one is better, of course.
In this case, your Python script has to return a formatted response, that PHP script can parse properly and determine variables with their values for example, your python code has to return something like that : ``` file_name=file.png;file_extension=png;creation_date=1/1/2015; ``` After that in your php code yo d...
62,015,339
``` x = Flatten()(vgg.output) variable = function (variable) ``` I can't find this type of expressions in python , can anyone help me to understand the above expression Thanks in advance
2020/05/26
[ "https://Stackoverflow.com/questions/62015339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5952135/" ]
The `Flatten()` function here, returns another function, which takes `vgg.output` as argument. This happens because everything in python is a first class object. So you can return a function as the return value of function. This will be clear with an example: Let's say we have a function `square` which returns the squ...
`x = Flattern()` is calling this function and assign returned data to `x`. `v = function` like `v` is `function` alias. And you can do `v()` to call it.
62,015,339
``` x = Flatten()(vgg.output) variable = function (variable) ``` I can't find this type of expressions in python , can anyone help me to understand the above expression Thanks in advance
2020/05/26
[ "https://Stackoverflow.com/questions/62015339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5952135/" ]
The `Flatten()` function here, returns another function, which takes `vgg.output` as argument. This happens because everything in python is a first class object. So you can return a function as the return value of function. This will be clear with an example: Let's say we have a function `square` which returns the squ...
Python has special syntax for inner functions. ``` def Flatten()(vgg.output): pass ``` Is basically the same as: ``` def Flatten(): def inner(vgg.output): pass ```
72,531,611
I have Miniconda3 on a Linux system (Ubuntu 22.04). The environment has Python 3.10 as well as a functioning (in Python) installation of PyTorch (installed following official instructions). I would like to setup a CMake project that uses PyTorch C++ API. The reason is not important and also I am aware that it's beta (...
2022/06/07
[ "https://Stackoverflow.com/questions/72531611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1559401/" ]
``` import os import pandas as pd base_dir = '/path/to/dir' #Get all files in the directory data_list = [] for file in os.listdir(base_dir): #If file is a json, construct it's full path and open it, append all json data to list if file.endswith('json'): json_path = os.path.join(base_dir, file) ...
You probably need to build a list of DataFrames. You may not be able to process every file in the given directory so try this: ``` import pandas as pd from glob import glob from os.path import join BASEDIR = 'Datasets' dataframes = [] for file in glob(join(BASEDIR, '*.json')): try: dataframes.append(pd.rea...
72,531,611
I have Miniconda3 on a Linux system (Ubuntu 22.04). The environment has Python 3.10 as well as a functioning (in Python) installation of PyTorch (installed following official instructions). I would like to setup a CMake project that uses PyTorch C++ API. The reason is not important and also I am aware that it's beta (...
2022/06/07
[ "https://Stackoverflow.com/questions/72531611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1559401/" ]
``` import os import pandas as pd base_dir = '/path/to/dir' #Get all files in the directory data_list = [] for file in os.listdir(base_dir): #If file is a json, construct it's full path and open it, append all json data to list if file.endswith('json'): json_path = os.path.join(base_dir, file) ...
``` import os import json #heres some information about get list of file in a folder: <https://www.geeksforgeeks.org/python-list-files-in-a-directory/> #heres some information about how to open a json file: <https://www.geeksforgeeks.org/read-json-file-using-python/> path = "./data" file_list = os.listdir(path) #opens...
38,690,035
I have a Python script that creates a Lambda script in AWS along with all the policies and triggers. I use python boto3 library for that. I create the zip file for the lambda as on-the-fly rather than uploading a static zip file from the hard drive. I use this simple code from below to create my zip file. It creates th...
2016/08/01
[ "https://Stackoverflow.com/questions/38690035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4163842/" ]
With the info above I was able to start the in-memory solution. The deployment of that zip file worked but I could not use the resulting function. Got error: ``` Unable to import module '<function-name>': No module named <function-name> ``` I got it to work by specifying the file permissions. I then use the in-mem...
I have experienced the exactly same problem you have. My solution is do NOT use on the fly zip file. Create a real zip file and add real file into it, and it just works. You can do that even in the lambda environment, by create filepath like "/tmp/yourfile.txt" you can create temp real file when lambda execute.
67,542,736
I'm trying to make lists of companies from long strings. The company names tend to be randomly dispersed through the strings, but they always have a comma and a space before the names ', ', and they always end in Inc, LLC, Corporation, or Corp. In addition, there is always a company listed at the very beginning of th...
2021/05/15
[ "https://Stackoverflow.com/questions/67542736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15930763/" ]
In C, the `for` loop is a "check before body" operation, you want the "check after body" variant, a `do while` loop, something like: ```c int xs[] = {1,2,3,4,5}; { int i = 0; do { foo(xs[i]); } while (xs[i++] != 4); } ``` You'll notice I've enclosed the entire chunk in its own scope (the outermos...
Try processing the loop as long as *the previous* element (if available) is not `4`: ``` int xs[] = {1,2,3,4,5}; for (int i = 0; i == 0 || xs[i - 1] != 4; i++) { foo(xs[i]); } ```
67,542,736
I'm trying to make lists of companies from long strings. The company names tend to be randomly dispersed through the strings, but they always have a comma and a space before the names ', ', and they always end in Inc, LLC, Corporation, or Corp. In addition, there is always a company listed at the very beginning of th...
2021/05/15
[ "https://Stackoverflow.com/questions/67542736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15930763/" ]
In C, the `for` loop is a "check before body" operation, you want the "check after body" variant, a `do while` loop, something like: ```c int xs[] = {1,2,3,4,5}; { int i = 0; do { foo(xs[i]); } while (xs[i++] != 4); } ``` You'll notice I've enclosed the entire chunk in its own scope (the outermos...
This may not be a direct answer to the original question, but I would strongly suggest against making a habit of parsing arrays like that (it's like a ticking bomb waiting to explode at a random point in time). I know you said you already know x is a member of xs, but when it is not (and this can accidentally happen f...
29,205,052
Iam create project in django-oscar with the help of <http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html> tutorial , i installed every packages which they mention in doc . after i run my project i getting (A server error occurred. Please contact the administrator. this error in ui) and the err...
2015/03/23
[ "https://Stackoverflow.com/questions/29205052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3632705/" ]
Try this ``` from oscar import get_core_apps INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.flatpages', 'compressor', ] + get_core_apps...
You dont import Oscar core apps. You need to import them and add to the INSTALLED\_APPS. You can doing this by importing `from oscar import get_core_apps` `get_core_apps` is a function that return (list) a default and required Oscar core apps. So you need to concatenate it. ``` INSTALLED_APPS = [ 'django.contrib....
24,331,551
I was wondering how I would be able to sort a whole array by the values in one of its columns. I have : ``` array([5,2,8,2,4]) ``` and: ``` array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) ``` I want to append the fi...
2014/06/20
[ "https://Stackoverflow.com/questions/24331551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3712008/" ]
You can use [numpy.argsort](http://docs.scipy.org/doc/numpy/reference/generated/numpy.argsort.html) to get a list with the sorted indices of your array. Using that you can then rearrange the columns of the matrix. ``` import numpy as np c = np.array([5,2,8,2,4]) a = np.array([[ 0, 1, 2, 3, 4], [...
You don't need numpy to do this; (although if you are using numpy, you can just use the `.transpose()` method of the array class. What this essentially does, is transpose your array so that it's `array[column][row]`, and then takes each columns, and pairs them with the sortKeys you provided in a list of tuples (the `z...
54,648,040
I would like to get ELK version through REST API or parse html. I search in API documentation without finding anything Re-edit: In python ... i'm not found better than ``` re.findall(r"version&quot;:&quot;(\d\.\d\.\d)&quot", requests.get(my_elk).content.decode())[0] ```
2019/02/12
[ "https://Stackoverflow.com/questions/54648040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3671796/" ]
Elasticsearch gives JSON, not HTML. So, you could use `jq` ``` $ curl -s localhost:9200 | jq '.version.number' 6.6.0 ``` In Python, please don't use `re` module... Use `json` module and actually parse that content
There's no HTML, but if you call `GET /` in Kibana's Console or `curl -XGET http://localhost:9200/`, the return will be: ``` { "name" : "instance-0000000039", "cluster_name" : "c2edd39f6fa24b0d8e5c34e8d1d19849", "cluster_uuid" : "VBkvp8OmTCaVuVvMioS3SA", "version" : { "number" : "6.6.0", "build_flavor"...
54,648,040
I would like to get ELK version through REST API or parse html. I search in API documentation without finding anything Re-edit: In python ... i'm not found better than ``` re.findall(r"version&quot;:&quot;(\d\.\d\.\d)&quot", requests.get(my_elk).content.decode())[0] ```
2019/02/12
[ "https://Stackoverflow.com/questions/54648040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3671796/" ]
Elasticsearch gives JSON, not HTML. So, you could use `jq` ``` $ curl -s localhost:9200 | jq '.version.number' 6.6.0 ``` In Python, please don't use `re` module... Use `json` module and actually parse that content
If you're already using the `requests` library, why not use the `json` method to parse the result? ``` requests.get(my_elk).json()["version"]["number"] ```
62,388,691
I am newer for a python language. I want to be read the data from the text file(multiple lines in the text file), Then use the data that read from the text file to execute with the dictionary function. ``` def readCmd(): f = open('cmd.txt', "r") line = f.readline() for line in f: print (line) ...
2020/06/15
[ "https://Stackoverflow.com/questions/62388691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11240783/" ]
You need to parse the input field value to an integer: ```js parseInt($('#corporateA').val(), 10) // 89 (integer) ``` Also, as a tip, avoid prefixing the dollar-sign to non-jQuery objects. ### Proper usage ```js let $corporateA = $('#corporateA'); // Storing a jQuery DOM object let valA = parseInt($corporateA.val(...
You need to parse the values of the input fields, which are of type string into numbers. There are two main strategies to achieve that. 1. Prefix every input field with a unary plus operator 2. Parse with the `parseInt` function If you fail to parse the string into numbers, the binary `plus` operator will do string c...
63,881,599
I am trying to use the [kubernetes-client](https://github.com/kubernetes-client) in python in order to create an horizontal pod autoscaler in kubernetes. To do so i make use of the [create\_namespaced\_horizontal\_pod\_autoscaler](https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AutoscalingV2beta...
2020/09/14
[ "https://Stackoverflow.com/questions/63881599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1488184/" ]
The above example permits the creation of a memory based hpa via the latest version of the [k8s python client](https://github.com/kubernetes-client/python) (v12.0.1). ``` my_metrics = [] my_metrics.append(client.V2beta2MetricSpec(type='Resource', resource= client.V2beta2ResourceMetricSource(name='memory',target=client...
Following error: > > > ``` > v2beta2.MetricTarget.AverageUtilization: readUint32: unexpected character: \ufffd, error found in #10 byte of .. > > ``` > > means that its expecting `Uint32` and you are passing a `string`: ``` target=client.V2beta2MetricTarget(average_utilization='50',type='Utilization') ...
12,439,762
Given this (among more...): ``` compile_coffee() { echo "Compile COFFEESCRIPT files..." i=0 for folder in ${COFFEE_FOLDER[*]} do for file in $folder/*.coffee do file_name=$(echo "$file" | awk -F "/" '{print $NF}' | awk -F "." '{print $1}') file_destination_path=$...
2012/09/15
[ "https://Stackoverflow.com/questions/12439762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/697150/" ]
This will give you 0.85 and 1.00 from your specified string, stored in `$values[1]` and `$values[2]` respectively. ``` $values = array(); preg_match('/Chop Suey<\/a><\/td><td align="right">([\d]+\.[\d]+)<\/td><td align="right">([\d]+\.[\d]+)<\/td>/', 'Chop Suey</a></td><td align="right">0.85</td><td align="right">1.00...
You could also be more dynamic with it. Instead of statically looking for "chop suey" why not look for other alignments. Here is a sample to that. (very basic). ``` preg_match("/\d+.\d+/",$content,$output); ``` (above match, would give you all the decimals you need in correct order.) ``` $output[0] (is the arra...
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This comes straight from Python Docs (<https://docs.python.org/3.3/using/windows.html>): **3.3.5. Executing scripts without the Python launcher** Without the Python launcher installed, Python scripts (files with the extension .py) will be executed by python.exe by default. This executable opens a terminal, which stay...
The solution that worked like a charm for me > From <https://www.tutorialexample.com/convert-python-script-to-exe-using-auto-py-to-exe-library-python-tutorial/> `pip install auto-py-to-exe` The GUI is available just by typing: `auto-py-to-exe` Then, I used this command to generate the desired output: `pyinstaller ...
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As an alternative to [py2exe](http://www.py2exe.org/) you could use the pyinstaller package with the `onefile` flag. This is a solution which works for python 3.x. 1. install pyinstaller via pip 2. Package your file to a single exe with the `onefile` flag ``` pyinstaller --onefile your_file.py ```
A better way (in my opinion): Create a shortcut: Set the target to `%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"` Start In: `C:\Users\MyUsername\Documents\` Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This comes straight from Python Docs (<https://docs.python.org/3.3/using/windows.html>): **3.3.5. Executing scripts without the Python launcher** Without the Python launcher installed, Python scripts (files with the extension .py) will be executed by python.exe by default. This executable opens a terminal, which stay...
[This tutorial](https://datatofish.com/batch-python-script/) shows how to create a batch file that runs a python script. Note that many of the other answers are out of date - py2exe is out of support past python 3.4. More info [here](https://stackoverflow.com/a/42310168/3206926).
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
[This tutorial](https://datatofish.com/batch-python-script/) shows how to create a batch file that runs a python script. Note that many of the other answers are out of date - py2exe is out of support past python 3.4. More info [here](https://stackoverflow.com/a/42310168/3206926).
A better way (in my opinion): Create a shortcut: Set the target to `%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"` Start In: `C:\Users\MyUsername\Documents\` Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
[This tutorial](https://datatofish.com/batch-python-script/) shows how to create a batch file that runs a python script. Note that many of the other answers are out of date - py2exe is out of support past python 3.4. More info [here](https://stackoverflow.com/a/42310168/3206926).
The solution that worked like a charm for me > From <https://www.tutorialexample.com/convert-python-script-to-exe-using-auto-py-to-exe-library-python-tutorial/> `pip install auto-py-to-exe` The GUI is available just by typing: `auto-py-to-exe` Then, I used this command to generate the desired output: `pyinstaller ...
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The simplest solution will be creating [batch file](https://en.wikipedia.org/wiki/Batch_file) containing command like: ``` c:\python27\python.exe c:\somescript.py ``` With this solution you will have to have installed python interpreter. If you need more portable solution you can try for e.g. [py2exe](http://www.py2...
A better way (in my opinion): Create a shortcut: Set the target to `%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"` Start In: `C:\Users\MyUsername\Documents\` Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The simplest solution will be creating [batch file](https://en.wikipedia.org/wiki/Batch_file) containing command like: ``` c:\python27\python.exe c:\somescript.py ``` With this solution you will have to have installed python interpreter. If you need more portable solution you can try for e.g. [py2exe](http://www.py2...
[This tutorial](https://datatofish.com/batch-python-script/) shows how to create a batch file that runs a python script. Note that many of the other answers are out of date - py2exe is out of support past python 3.4. More info [here](https://stackoverflow.com/a/42310168/3206926).
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
A better way (in my opinion): Create a shortcut: Set the target to `%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"` Start In: `C:\Users\MyUsername\Documents\` Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.
The solution that worked like a charm for me > From <https://www.tutorialexample.com/convert-python-script-to-exe-using-auto-py-to-exe-library-python-tutorial/> `pip install auto-py-to-exe` The GUI is available just by typing: `auto-py-to-exe` Then, I used this command to generate the desired output: `pyinstaller ...
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This comes straight from Python Docs (<https://docs.python.org/3.3/using/windows.html>): **3.3.5. Executing scripts without the Python launcher** Without the Python launcher installed, Python scripts (files with the extension .py) will be executed by python.exe by default. This executable opens a terminal, which stay...
A better way (in my opinion): Create a shortcut: Set the target to `%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"` Start In: `C:\Users\MyUsername\Documents\` Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.
37,219,045
I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?
2016/05/13
[ "https://Stackoverflow.com/questions/37219045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This comes straight from Python Docs (<https://docs.python.org/3.3/using/windows.html>): **3.3.5. Executing scripts without the Python launcher** Without the Python launcher installed, Python scripts (files with the extension .py) will be executed by python.exe by default. This executable opens a terminal, which stay...
As an alternative to [py2exe](http://www.py2exe.org/) you could use the pyinstaller package with the `onefile` flag. This is a solution which works for python 3.x. 1. install pyinstaller via pip 2. Package your file to a single exe with the `onefile` flag ``` pyinstaller --onefile your_file.py ```
53,780,882
I have multiple times as a string: ``` "2018-12-14 11:20:16","2018-12-14 11:14:01","2018-12-14 11:01:58","2018-12-14 10:54:21" ``` I want to calculate the average time difference between all these times. The above example would be: ``` 2018-12-14 11:20:16 - 2018-12-14 11:14:01 = 6 minutes 15 seconds 2018-12-14 11:...
2018/12/14
[ "https://Stackoverflow.com/questions/53780882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323427/" ]
You have a bunch of problems. I'm not going to give you solutions to all of these. Just hints to get you started. I assume you know... * ... how to convert a time string to a `datetime.datetime` object, * ... how to calculate the difference between two, i.e., a `datetime.timedelta`, * ... how to compute a mean value ...
``` from datetime import datetime import numpy as np ts_list = ["2018-12-14 11:20:16","2018-12-14 11:14:01","2018-12-14 11:01:58","2018-12-14 10:54:21"] dif_list = [] for i in range(len(ts_list)-1): dif_list.append((datetime.strptime(ts_list[i], '%Y-%m-%d %H:%M:%S')-datetime.strptime(ts_list[i+1], '%Y-%m-%d %H:%M:...
44,367,508
I have a for loop which runs a Python script ~100 times on 100 different input folders. The python script is most efficient on 2 cores, and I have 50 cores available. So I'd like to use GNU parallel to run the script on 25 folders at a time. Here's my for loop (works fine, but is sequential of course), the python scr...
2017/06/05
[ "https://Stackoverflow.com/questions/44367508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084470/" ]
Replace `echo $folders | parallel ...` with `echo "$folders" | parallel ...`. Without the double quotes, the shell parses spaces in `$folders` and passes them as separate arguments to `echo`, which causes them to be printed on one line. `parallel` provides each line as argument to the job. To avoid such quoting issue...
you can pipe find directly to parallel: ``` find /home/rob/PartitionFinder/ -maxdepth 2 -type d | parallel -P 25 python script.py --raxml --quick --no-ml-tree {} --force -p 2 ``` If you want to keep the string in `$folder`, you can pipe the echo to xargs. ``` echo $folders | xargs -n 1 | parallel -P 25 python scri...
44,367,508
I have a for loop which runs a Python script ~100 times on 100 different input folders. The python script is most efficient on 2 cores, and I have 50 cores available. So I'd like to use GNU parallel to run the script on 25 folders at a time. Here's my for loop (works fine, but is sequential of course), the python scr...
2017/06/05
[ "https://Stackoverflow.com/questions/44367508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084470/" ]
you can pipe find directly to parallel: ``` find /home/rob/PartitionFinder/ -maxdepth 2 -type d | parallel -P 25 python script.py --raxml --quick --no-ml-tree {} --force -p 2 ``` If you want to keep the string in `$folder`, you can pipe the echo to xargs. ``` echo $folders | xargs -n 1 | parallel -P 25 python scri...
You can create a `Makefile` like this: ``` #!/usr/bin/make -f FOLDERS=$(shell find /home/rob/PartitionFinder/ -maxdepth 2 -type d) all: ${FOLDERS} # To execute the find before the all find_folders: @ echo $(FOLDERS) > /dev/null ${FOLDERS}: find_folders @ python script.py --raxml --quick --no-ml-tree $@ --f...
44,367,508
I have a for loop which runs a Python script ~100 times on 100 different input folders. The python script is most efficient on 2 cores, and I have 50 cores available. So I'd like to use GNU parallel to run the script on 25 folders at a time. Here's my for loop (works fine, but is sequential of course), the python scr...
2017/06/05
[ "https://Stackoverflow.com/questions/44367508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084470/" ]
Replace `echo $folders | parallel ...` with `echo "$folders" | parallel ...`. Without the double quotes, the shell parses spaces in `$folders` and passes them as separate arguments to `echo`, which causes them to be printed on one line. `parallel` provides each line as argument to the job. To avoid such quoting issue...
You can create a `Makefile` like this: ``` #!/usr/bin/make -f FOLDERS=$(shell find /home/rob/PartitionFinder/ -maxdepth 2 -type d) all: ${FOLDERS} # To execute the find before the all find_folders: @ echo $(FOLDERS) > /dev/null ${FOLDERS}: find_folders @ python script.py --raxml --quick --no-ml-tree $@ --f...
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
If you are using Python for IOS, the following should work, although I haven't yet tried it myself. Email the program to your own e-mail account as text. Then read the e-mail message on your iPad in any one of several e-mail applications. Cut and paste the text from the e-mail message into the python editor. Don't cu...
I use Python 2.7 for IOS and download source python files through iFunBox into /var/mobile/Applications/Python 2.7 for IOS/Documents/User Scripts. Nevertheless I can't recommend this application as it's quite buggy and very slow when editing code.
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
If you're just running command-line Python, then you can edit it and/or upload it to a server and then run it from an iPad ssh terminal client. I know that's not the same as pushing it onto the iPad, and it requires a server and an internet connection, but it's the easiest way. Otherwise, include a Python interpreter ...
Pythonista for Ipad: save a script from the web in the Ipad ----------------------------------------------------------- Pythonista is a great app for python on the ipad. If you use a bluetooth keyboard it can be also easier to digit (I use the logitech keyboard and it's great). Save it to your github repository (or an...
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
you may be interesting in <https://www.pythonanywhere.com> project. I am using it on ipad too.
I use Python 2.7 for IOS and download source python files through iFunBox into /var/mobile/Applications/Python 2.7 for IOS/Documents/User Scripts. Nevertheless I can't recommend this application as it's quite buggy and very slow when editing code.
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
Pythonista for Ipad: save a script from the web in the Ipad ----------------------------------------------------------- Pythonista is a great app for python on the ipad. If you use a bluetooth keyboard it can be also easier to digit (I use the logitech keyboard and it's great). Save it to your github repository (or an...
Use the eclipse Che editor on Codenvy.com [Codenvy Websife](https://codenvy.com/) It's a browser-based IDE and can be used from any device that has a web browser.
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
If you are using Python for IOS, the following should work, although I haven't yet tried it myself. Email the program to your own e-mail account as text. Then read the e-mail message on your iPad in any one of several e-mail applications. Cut and paste the text from the e-mail message into the python editor. Don't cu...
If you're just running command-line Python, then you can edit it and/or upload it to a server and then run it from an iPad ssh terminal client. I know that's not the same as pushing it onto the iPad, and it requires a server and an internet connection, but it's the easiest way. Otherwise, include a Python interpreter ...
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
you may be interesting in <https://www.pythonanywhere.com> project. I am using it on ipad too.
If you're just running command-line Python, then you can edit it and/or upload it to a server and then run it from an iPad ssh terminal client. I know that's not the same as pushing it onto the iPad, and it requires a server and an internet connection, but it's the easiest way. Otherwise, include a Python interpreter ...
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
I use Python 2.7 for IOS and download source python files through iFunBox into /var/mobile/Applications/Python 2.7 for IOS/Documents/User Scripts. Nevertheless I can't recommend this application as it's quite buggy and very slow when editing code.
Use the eclipse Che editor on Codenvy.com [Codenvy Websife](https://codenvy.com/) It's a browser-based IDE and can be used from any device that has a web browser.
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
If you're just running command-line Python, then you can edit it and/or upload it to a server and then run it from an iPad ssh terminal client. I know that's not the same as pushing it onto the iPad, and it requires a server and an internet connection, but it's the easiest way. Otherwise, include a Python interpreter ...
Use the eclipse Che editor on Codenvy.com [Codenvy Websife](https://codenvy.com/) It's a browser-based IDE and can be used from any device that has a web browser.
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
you may be interesting in <https://www.pythonanywhere.com> project. I am using it on ipad too.
Use the eclipse Che editor on Codenvy.com [Codenvy Websife](https://codenvy.com/) It's a browser-based IDE and can be used from any device that has a web browser.
12,002,051
Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?
2012/08/17
[ "https://Stackoverflow.com/questions/12002051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508702/" ]
If you're just running command-line Python, then you can edit it and/or upload it to a server and then run it from an iPad ssh terminal client. I know that's not the same as pushing it onto the iPad, and it requires a server and an internet connection, but it's the easiest way. Otherwise, include a Python interpreter ...
I use Python 2.7 for IOS and download source python files through iFunBox into /var/mobile/Applications/Python 2.7 for IOS/Documents/User Scripts. Nevertheless I can't recommend this application as it's quite buggy and very slow when editing code.
44,952,354
I would like to use segment of the same string in a formatted string. ```python input_string = 'abcdefhijk' result_string = "A's name is abcd-defh; he does hijk" ``` The intuitive solution is ```python "A's name is {0[0:4]}-{0{[3:7]}; he does {0[6:10]}".format(input_string) ``` And this obviously doesn't work. Wh...
2017/07/06
[ "https://Stackoverflow.com/questions/44952354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5112950/" ]
In Python 3.6, you can make a similar construct to your "intuitive solution" with [f-strings](https://www.python.org/dev/peps/pep-0498/): ``` >>> input_string = 'abcdefhijk' >>> f"A's name is {input_string[0:4]}-{input_string[3:7]}; he does {input_string[6:10]}" "A's name is abcd-defh; he does hijk" ```
Have you tried the below ``` result_string = "A's name is %s-%s; he does %s" %(input_string[:4], input_string[3:7], input_string[6:10]) ```
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
This one worked for me after wasting hours: ``` pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy ```
The following worked for me. I'm currently using `Python 3.10.8`, installed using `brew`. And currently, when installing `numpy==1.23.4`, `setuptools < 60.0.0` is required. I'm using `(brew --prefix)/bin/python3 -m pip` for explicitly calling the `pip` from `python 3.10` installed by `brew`. Here are the versions I...
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
This one worked for me after wasting hours: ``` pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy ```
According to [this Github issue](https://github.com/scipy/scipy/issues/16974), Scipy doesn't work on MacOS 11 (Big Sur). If none of these solutions are working for you I'd suggest updating your OS.
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
[This solution](https://github.com/numpy/numpy/issues/17784#issuecomment-729950525) worked on my M1 machine with `pyenv`: ``` brew install openblas OPENBLAS="$(brew --prefix openblas)" pip install numpy scipy ```
For those who need it for short-term purposes and don't want too much hustle - it seems to work with python 3.6.4 and scipy 1.5.4 out of the box (Big Sur 11.5.2, M1 chip).
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
It's possible to install on regular arm64 brew python, you need to compile it yourself. If `numpy` is already installed (from wheels) you'll need to uninstall it: ``` pip3 uninstall -y numpy pythran ``` I had to compile `numpy`, which requires `cython` and `pybind11`: ``` pip3 install cython pybind11 ``` Then `n...
In addition, if someone has this error message> ``` ########### CLIB COMPILER OPTIMIZATION ########### Platform : Architecture: aarch64 Compiler : clang CPU baseline : Requested : 'min' Enabled : none Flags : none Extra checks: none CPU dispatch : Requested : 'max -xop -fma4' ...
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
[This solution](https://github.com/numpy/numpy/issues/17784#issuecomment-729950525) worked on my M1 machine with `pyenv`: ``` brew install openblas OPENBLAS="$(brew --prefix openblas)" pip install numpy scipy ```
According to [this Github issue](https://github.com/scipy/scipy/issues/16974), Scipy doesn't work on MacOS 11 (Big Sur). If none of these solutions are working for you I'd suggest updating your OS.
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
For those who need it for short-term purposes and don't want too much hustle - it seems to work with python 3.6.4 and scipy 1.5.4 out of the box (Big Sur 11.5.2, M1 chip).
I use `conda install scipy` to resolve this problem. Conda have a custom version of scipy for Apple M1. Update macOS to 12 if you don't want to use Conda.
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
For those who need it for short-term purposes and don't want too much hustle - it seems to work with python 3.6.4 and scipy 1.5.4 out of the box (Big Sur 11.5.2, M1 chip).
The following worked for me. I'm currently using `Python 3.10.8`, installed using `brew`. And currently, when installing `numpy==1.23.4`, `setuptools < 60.0.0` is required. I'm using `(brew --prefix)/bin/python3 -m pip` for explicitly calling the `pip` from `python 3.10` installed by `brew`. Here are the versions I...
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
For me the easiest solutions: ``` brew install scipy ``` Probably good idea to edit the PATH, so the homebrew version will be the default.
I use `conda install scipy` to resolve this problem. Conda have a custom version of scipy for Apple M1. Update macOS to 12 if you don't want to use Conda.
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
It's possible to install on regular arm64 brew python, you need to compile it yourself. If `numpy` is already installed (from wheels) you'll need to uninstall it: ``` pip3 uninstall -y numpy pythran ``` I had to compile `numpy`, which requires `cython` and `pybind11`: ``` pip3 install cython pybind11 ``` Then `n...
For those who need it for short-term purposes and don't want too much hustle - it seems to work with python 3.6.4 and scipy 1.5.4 out of the box (Big Sur 11.5.2, M1 chip).
65,745,683
I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using ``` python3 -m pip install scipy ``` I also tried installing everything from brew, and `import scipy` works, but using it gives a seg fault....
2021/01/16
[ "https://Stackoverflow.com/questions/65745683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206216/" ]
This one worked for me after wasting hours: ``` pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy ```
I managed to get scipy installed on Apple Silicon. I mostly followed the instructions by lutzroeder here: <https://github.com/scipy/scipy/issues/13409> Those instructions weren't successful for me, but running 'pip3 install scipy' worked afterwards. I think this fixed the problem for me: ``` /opt/homebrew/bin/brew in...
65,560,546
I have a multi index dataframe like this: ``` PID Fid x y A 1 2 3 2 6 1 3 4 6 B 1 3 5 2 2 4 3 5 7 ``` I would like to delete the rows with the highest x-value per patient (PID). I need to get a new dataframe...
2021/01/04
[ "https://Stackoverflow.com/questions/65560546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14564287/" ]
You can try this: ``` idx = df.groupby(level=0)['x'].idxmax() df[~df.index.isin(idx)] x y PID Fid A 1 2 3 3 4 6 B 1 3 5 2 2 4 ``` Or You can use `pd.Index.difference` here. ``` df.loc[df.index.difference(df['x'].groupby(level=0).idxmax())] #Use level=0 if index is unnam...
Use [`GroupBy.transform`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.transform.html) for repeat max values per groups, compare by [`Series.ne`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.ne.html) for not equal and filter in [`boolean inde...
45,619,217
I created my own user model by sub-classing AbstractBaseUser as is recommended by the docs. The goal here was to use a new field called mob\_phone as the identifying field for registration and log-in. It works a charm - for the first user. It sets the username field as nothing - blank.But when I register a second user...
2017/08/10
[ "https://Stackoverflow.com/questions/45619217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5644300/" ]
Okay I'm an idiot. Literally seconds after posting this the obvious solution occurred to me: ``` username = models.CharField(max_length=40, unique=False, default='') ``` Just override the username field and make it non unique. Rubber duck theory in action....
It might be because you would have already entered some data in database which must be contradicting to the constraint. So try deleting that data or whole database and then run the command again.
607,931
I've deployed trac using apache/mod\_wsgi (no SSL) (preferable, since the problem I'm facing with CGI is performance), and it works fine WITHOUT SVN integration. But I actually need SVN, so when I configure the repository path (i.e: repository\_dir = c:/projects/svn/my\_project) I can't even get my project TRAC to even...
2009/03/03
[ "https://Stackoverflow.com/questions/607931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73377/" ]
Set a break point on the line that reads: NewFaqDropDownCategory.DataBind() and one in your event handler (NewFaqDropDownCategory\_SelectedIndexChanged). I suspect the databind is being called right before your NewFaqDropDownCategory\_SelectedIndexChanged event fires causing your selected value to change. If so, you n...
I think there is a bug in your LINQ query for the second drop down box ``` Dim faqs = (From f In db.faqs Where f.category = NewFaqDropDownCategory.SelectedValue) ``` Here you are comparing SelectedValue to category. Yet in the first combobox you said that the DataValueField should be category\_id. Try changing f.cat...
607,931
I've deployed trac using apache/mod\_wsgi (no SSL) (preferable, since the problem I'm facing with CGI is performance), and it works fine WITHOUT SVN integration. But I actually need SVN, so when I configure the repository path (i.e: repository\_dir = c:/projects/svn/my\_project) I can't even get my project TRAC to even...
2009/03/03
[ "https://Stackoverflow.com/questions/607931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73377/" ]
I had the same problem. Found I forgot to look if I was posting back to the page or not and I was binding my DropDownList control in the `Page_Load` event of the page. I had forgot to use: ``` if (!IsPostBack) { .... do databind .... } ```
I think there is a bug in your LINQ query for the second drop down box ``` Dim faqs = (From f In db.faqs Where f.category = NewFaqDropDownCategory.SelectedValue) ``` Here you are comparing SelectedValue to category. Yet in the first combobox you said that the DataValueField should be category\_id. Try changing f.cat...
607,931
I've deployed trac using apache/mod\_wsgi (no SSL) (preferable, since the problem I'm facing with CGI is performance), and it works fine WITHOUT SVN integration. But I actually need SVN, so when I configure the repository path (i.e: repository\_dir = c:/projects/svn/my\_project) I can't even get my project TRAC to even...
2009/03/03
[ "https://Stackoverflow.com/questions/607931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73377/" ]
Set a break point on the line that reads: NewFaqDropDownCategory.DataBind() and one in your event handler (NewFaqDropDownCategory\_SelectedIndexChanged). I suspect the databind is being called right before your NewFaqDropDownCategory\_SelectedIndexChanged event fires causing your selected value to change. If so, you n...
I had the same problem. Found I forgot to look if I was posting back to the page or not and I was binding my DropDownList control in the `Page_Load` event of the page. I had forgot to use: ``` if (!IsPostBack) { .... do databind .... } ```
67,366,722
I am having issue parsing an xml result using python. I tried using etree.Element(text), but the error says Invalid tag name. Does anyone know if this is actually an xml and any way of parsing the result using a standard package? Thank you! ``` import requests, sys, json from lxml import etree response = requests.get(...
2021/05/03
[ "https://Stackoverflow.com/questions/67366722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14304103/" ]
You're using the wrong method to parse your XML. The `etree.Element` class is for *creating* a single XML element. For example: ``` >>> a = etree.Element('a') >>> a <Element a at 0x7f8c9040e180> >>> etree.tostring(a) b'<a/>' ``` As Jayvee has pointed how, to parse XML contained in a string you use the `etree.fromstr...
You can check if the xml is well formed by try converting it: ``` import requests, sys, json from lxml import etree response = requests.get("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=snp&id=1593319917&report=XML") text=response.text try: doc=etree.fromstring(text) print("valid") except: ...
73,142,014
Am using the following ETL pipeline to get data into BigQuery. Data source are .csv & .xls files from a URL posted daily at 3 pm. Cloud Scheduler publishes a message to a cloud pub/sub topic at 3:05 pm. Pub/Sub pushes/triggers the subscribers-cloud functions When triggered, these cloud functions (python script) downloa...
2022/07/27
[ "https://Stackoverflow.com/questions/73142014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12322651/" ]
In your architecture, Dataflow can only replace the PubSub + Cloud Functions. You still need a scheduler to run a dataflow (based on a template, maybe your custom template). But, before using dataflow, why do you need it? I'm in charge of a datalake, to ingest data from different sources, but, because each element to ...
I do this kind of thing all the time and I can see why you'd wonder if there's a cleaner way. We use Composer (Ariflow) in GCP. In your scenario we would create one DAG with four sequential taks: 1. Copy file from URL to local bucket 2. Load file from local bucket to stage table 3. Merge stage table into final destina...
34,405,936
When I try to do `python manage.py syncdb` in my Django app, I get the error **ImportError: No module named azure.storage.blob**. But thing is, the following packages are installed if one does `pip freeze`: `azure-common==1.0.0 azure-mgmt==0.20.1 azure-mgmt-common==0.20.0 azure-mgmt-compute==0.20.0 azure-mgmt-network=...
2015/12/21
[ "https://Stackoverflow.com/questions/34405936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4936905/" ]
I had a similar issue. To alleviate that, I followed this discussion here: <https://github.com/Azure/azure-storage-python/issues/51#issuecomment-148151993> Basically, try `pip install azure==0.11.1` before trying `syncdb`, and I'm confident it will work for you!
There is a thread similar with yours, please check my answer for the thread [Unable to use azure SDK in Python](https://stackoverflow.com/questions/34213764/unable-to-use-azure-sdk-in-python). Based on my experience, Python imports the third-party library packages from some library paths that you can check them thru c...
7,548,562
I've been getting weird results and I finally noticed that my habit of putting spaces in a tuple is causing the problem. If you can reproduce this problem and tell me why it works this way, you would be saving what's left of my hair. Thanks! ``` jcomeau@intrepid:/tmp$ cat haversine.py #!/usr/bin/python def dms_to_floa...
2011/09/25
[ "https://Stackoverflow.com/questions/7548562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493161/" ]
The spaces should make no difference. The difference is due to the case: `SW` vs `Sw`. You don't check for `SW` here: ``` compass in ['S', 'W', 'Sw']] ``` Perhaps change it to this: ``` compass.upper() in ['S', 'W', 'SW']] ```
Presuming that the "degrees" relate to degrees of latitude or longitude, I can't imagine why "SW" is treated as a viable option. Latitude is either N or S. Longitude is either E or W. Please explain. Based on your sample of size 1, user input is not to be trusted. Consider checking the input, or at least ensuring that...
64,120,358
I try to make simple 3D plot with plot\_surface of matplotlib, below is the minimum example: ``` import numpy as np import matplotlib.pyplot as plt from matplotlib import cm x_test = np.arange(0.001, 0.01, 0.0005) y_test = np.arange(0.1, 100, 0.05) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') Xtest,...
2020/09/29
[ "https://Stackoverflow.com/questions/64120358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14361102/" ]
It's possible to have 2 nested scroll viewers in Xamarin.Forms. Notice how it says 'scroll viewers ***should not*** be nested, this means that it is certainly possible but it is not recommended. I think nested scroll viewers creates a bad user-experience and makes for a clunky app, especially for Xamarin.Forms; but ag...
According to your screenshot, i make a code sample for your reference. **Xaml:** ``` <ScrollView Orientation="Vertical"> <StackLayout Orientation="Horizontal"> <BoxView BackgroundColor="Blue" WidthRequest="150" /> <StackLayout Orientation="Vertical"> <ScrollView Orientation="Horizonta...
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**Shortcuts**: * `Shift` + `Command` + `L`: Show Library. * `Shift` + `Command` + `M`: Show Media Library. --- Xcode 10 has added a toolbar button to access the Object Library. [![enter image description here](https://i.stack.imgur.com/3J26u.png)](https://i.stack.imgur.com/3J26u.png) From a [thread](https://forums...
The library can be opened via a new toolbar button, the View → Libraries menu, or the `Shift` + `Command` + `L` keyboard shortcut.The media library is available via a long press on the toolbar button, the View → Libraries menu, or the `Shift` + `Command` + `M` keyboard shortcut. Library content has moved from the bott...
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**XCode 11 - Object library location** Click on the plus icon on the top right corner of Xcode topbar. [![enter image description here](https://i.stack.imgur.com/UdxJz.jpg)](https://i.stack.imgur.com/UdxJz.jpg)
In Xcode 11 use Shift + Command + L to show the Object Library.
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**Shortcuts**: * `Shift` + `Command` + `L`: Show Library. * `Shift` + `Command` + `M`: Show Media Library. --- Xcode 10 has added a toolbar button to access the Object Library. [![enter image description here](https://i.stack.imgur.com/3J26u.png)](https://i.stack.imgur.com/3J26u.png) From a [thread](https://forums...
**XCode 11 - Object library location** Click on the plus icon on the top right corner of Xcode topbar. [![enter image description here](https://i.stack.imgur.com/UdxJz.jpg)](https://i.stack.imgur.com/UdxJz.jpg)
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**XCode 11 - Object library location** Click on the plus icon on the top right corner of Xcode topbar. [![enter image description here](https://i.stack.imgur.com/UdxJz.jpg)](https://i.stack.imgur.com/UdxJz.jpg)
The library can be opened via a new toolbar button, the View → Libraries menu, or the `Shift` + `Command` + `L` keyboard shortcut.The media library is available via a long press on the toolbar button, the View → Libraries menu, or the `Shift` + `Command` + `M` keyboard shortcut. Library content has moved from the bott...
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
What the existing answers (so far) neglect to mention is that if you hold `Option` as you summon the Library window — i.e., press `Shift` + `Option` + `Command` + `L`, or hold `Option` while clicking the Library button in the toolbar — the window stays open, *permanently*, until you explicitly close it with its Close b...
In Xcode 11 use Shift + Command + L to show the Object Library.
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
What the existing answers (so far) neglect to mention is that if you hold `Option` as you summon the Library window — i.e., press `Shift` + `Option` + `Command` + `L`, or hold `Option` while clicking the Library button in the toolbar — the window stays open, *permanently*, until you explicitly close it with its Close b...
Xcode 12 users can find the same option as the Xcode 11 as written above. `Shift` `Command` `L` to bring up the Objects/Image/Color and other context-sensitive libraries. There is also the `+` sign at the top right of the window titled Library when you mouseover. This drove me crazy trying to follow a tutorial that ...
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**Shortcuts**: * `Shift` + `Command` + `L`: Show Library. * `Shift` + `Command` + `M`: Show Media Library. --- Xcode 10 has added a toolbar button to access the Object Library. [![enter image description here](https://i.stack.imgur.com/3J26u.png)](https://i.stack.imgur.com/3J26u.png) From a [thread](https://forums...
Xcode 12 users can find the same option as the Xcode 11 as written above. `Shift` `Command` `L` to bring up the Objects/Image/Color and other context-sensitive libraries. There is also the `+` sign at the top right of the window titled Library when you mouseover. This drove me crazy trying to follow a tutorial that ...
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**XCode 11 - Object library location** Click on the plus icon on the top right corner of Xcode topbar. [![enter image description here](https://i.stack.imgur.com/UdxJz.jpg)](https://i.stack.imgur.com/UdxJz.jpg)
Xcode 12 users can find the same option as the Xcode 11 as written above. `Shift` `Command` `L` to bring up the Objects/Image/Color and other context-sensitive libraries. There is also the `+` sign at the top right of the window titled Library when you mouseover. This drove me crazy trying to follow a tutorial that ...
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
**Shortcuts**: * `Shift` + `Command` + `L`: Show Library. * `Shift` + `Command` + `M`: Show Media Library. --- Xcode 10 has added a toolbar button to access the Object Library. [![enter image description here](https://i.stack.imgur.com/3J26u.png)](https://i.stack.imgur.com/3J26u.png) From a [thread](https://forums...
In Xcode 11 use Shift + Command + L to show the Object Library.
50,962,836
I am new with python-pptx. But I am familiar with its basic working. I have searched a lot but I could not find a way to change a particular text by another text in all slides. That text may be in any text\_frame of a slide. like all slides in a ppt have 'java' keyword, I want to change it by 'python' using python pptx...
2018/06/21
[ "https://Stackoverflow.com/questions/50962836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8847530/" ]
The library can be opened via a new toolbar button, the View → Libraries menu, or the `Shift` + `Command` + `L` keyboard shortcut.The media library is available via a long press on the toolbar button, the View → Libraries menu, or the `Shift` + `Command` + `M` keyboard shortcut. Library content has moved from the bott...
Xcode 12 users can find the same option as the Xcode 11 as written above. `Shift` `Command` `L` to bring up the Objects/Image/Color and other context-sensitive libraries. There is also the `+` sign at the top right of the window titled Library when you mouseover. This drove me crazy trying to follow a tutorial that ...
35,678,885
I am following an online course for making web apps with python/mongo/bootstrap. I install mongodb using default settings I run mongod in powershell from install directory ``` C:\Program Files\MongoDB\Server\3.2\bin>mongod 2016-02-27T23:31:14.684-0500 I CONTROL [initandlisten] MongoDB starting : pid=2456 port=2701...
2016/02/28
[ "https://Stackoverflow.com/questions/35678885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5885288/" ]
The easiest way to get a variable by name is to search for it in the [`tf.global_variables()`](https://www.tensorflow.org/api_docs/python/tf/global_variables) collection: ``` var_23 = [v for v in tf.global_variables() if v.name == "Variable_23:0"][0] ``` This works well for ad hoc reuse of existing variables. A more...
If you want to get any stored variables from a model, use`tf.train.load_variable("model_folder_name","Variable name")`
35,678,885
I am following an online course for making web apps with python/mongo/bootstrap. I install mongodb using default settings I run mongod in powershell from install directory ``` C:\Program Files\MongoDB\Server\3.2\bin>mongod 2016-02-27T23:31:14.684-0500 I CONTROL [initandlisten] MongoDB starting : pid=2456 port=2701...
2016/02/28
[ "https://Stackoverflow.com/questions/35678885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5885288/" ]
The easiest way to get a variable by name is to search for it in the [`tf.global_variables()`](https://www.tensorflow.org/api_docs/python/tf/global_variables) collection: ``` var_23 = [v for v in tf.global_variables() if v.name == "Variable_23:0"][0] ``` This works well for ad hoc reuse of existing variables. A more...
Based on @mrry 's answer, I think it would be better to create and use the following function, since there's also local variables, and other variables that are not in global variables (they are in different collections): ``` def get_var_by_name(query_name, var_list): """ Get Variable by name e.g. loca...
35,678,885
I am following an online course for making web apps with python/mongo/bootstrap. I install mongodb using default settings I run mongod in powershell from install directory ``` C:\Program Files\MongoDB\Server\3.2\bin>mongod 2016-02-27T23:31:14.684-0500 I CONTROL [initandlisten] MongoDB starting : pid=2456 port=2701...
2016/02/28
[ "https://Stackoverflow.com/questions/35678885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5885288/" ]
The `get_variable()` function creates a new variable or returns one created earlier by `get_variable()`. It won't return a variable created using `tf.Variable()`. Here's a quick example: ``` >>> with tf.variable_scope("foo"): ... bar1 = tf.get_variable("bar", (2,3)) # create ... >>> with tf.variable_scope("foo", re...
If you want to get any stored variables from a model, use`tf.train.load_variable("model_folder_name","Variable name")`
35,678,885
I am following an online course for making web apps with python/mongo/bootstrap. I install mongodb using default settings I run mongod in powershell from install directory ``` C:\Program Files\MongoDB\Server\3.2\bin>mongod 2016-02-27T23:31:14.684-0500 I CONTROL [initandlisten] MongoDB starting : pid=2456 port=2701...
2016/02/28
[ "https://Stackoverflow.com/questions/35678885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5885288/" ]
The `get_variable()` function creates a new variable or returns one created earlier by `get_variable()`. It won't return a variable created using `tf.Variable()`. Here's a quick example: ``` >>> with tf.variable_scope("foo"): ... bar1 = tf.get_variable("bar", (2,3)) # create ... >>> with tf.variable_scope("foo", re...
Based on @mrry 's answer, I think it would be better to create and use the following function, since there's also local variables, and other variables that are not in global variables (they are in different collections): ``` def get_var_by_name(query_name, var_list): """ Get Variable by name e.g. loca...
54,404,263
I have a python list A and a python list B with words as list elements. I need to check how often the list elements from list B are contained in list A. Is there a python method or how can I implement this efficient? The python intersection method only tells me that a list element from list B occurs in list A, but not...
2019/01/28
[ "https://Stackoverflow.com/questions/54404263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10478079/" ]
``` import collections counter_A = collections.Counter(A) for word in B: print(word, '->', counter_A[word]) ```
You could convert list B to a set, so that checking if the element is in B is faster. Then create a dictionary to count the amount of times that the element is in A if the element is also in the set of B As mentioned in the comments `collections.Counter` does the "heavy lifting" for you
54,404,263
I have a python list A and a python list B with words as list elements. I need to check how often the list elements from list B are contained in list A. Is there a python method or how can I implement this efficient? The python intersection method only tells me that a list element from list B occurs in list A, but not...
2019/01/28
[ "https://Stackoverflow.com/questions/54404263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10478079/" ]
``` import collections counter_A = collections.Counter(A) for word in B: print(word, '->', counter_A[word]) ```
> > The python intersection method only tells me that a list element from > list B occurs in list A, but not how often. > > > Correct, but you can build on this principle. Iterate over the intersection using a dictionary comprehension: ``` from collections import Counter A = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5] B = [...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
I'm having a similar need and I read current Pandas version supports a directory path as argument for the [read\_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_parquet.html) function. So you can read multiple parquet files like this: ``` import pandas as pd df = pd.read_parquet('path/t...
If you are going to copy the files over to your local machine and run your code you could do something like this. The code below assumes that you are running your code in the same directory as the parquet files. It also assumes the naming of files as your provided above: "order. ex: par\_file1,par\_file2,par\_file3 and...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
I ran into this question looking to see if pandas can natively read partitioned parquet datasets. I have to say that the current answer is unnecessarily verbose (making it difficult to parse). I also imagine that it's not particularly efficient to be constantly opening/closing file handles then scanning to the end of t...
a small change for those trying to read remote files, which helps to read it faster (direct read\_parquet for remote files was doing this much slower for me): ``` import io merged = [] # remote_reader = ... <- init some remote reader, for example AzureDLFileSystem() for f in files: with remote_reader.open(f, 'rb')...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
I'm having a similar need and I read current Pandas version supports a directory path as argument for the [read\_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_parquet.html) function. So you can read multiple parquet files like this: ``` import pandas as pd df = pd.read_parquet('path/t...
a small change for those trying to read remote files, which helps to read it faster (direct read\_parquet for remote files was doing this much slower for me): ``` import io merged = [] # remote_reader = ... <- init some remote reader, for example AzureDLFileSystem() for f in files: with remote_reader.open(f, 'rb')...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
This helped me to load all parquet files into one data frame ``` import glob files = glob.glob("*.snappy.parquet") data = [pd.read_parquet(f,engine='fastparquet') for f in files] merged_data = pd.concat(data,ignore_index=True) ```
You can use Dask to read in the multiple Parquet files and write them to a single CSV. Dask accepts an asterisk (\*) as wildcard / glob character to match related filenames. Make sure to set `single_file` to `True` and `index` to `False` when writing the CSV file. ```py import pandas as pd import numpy as np # crea...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
I'm having a similar need and I read current Pandas version supports a directory path as argument for the [read\_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_parquet.html) function. So you can read multiple parquet files like this: ``` import pandas as pd df = pd.read_parquet('path/t...
This helped me to load all parquet files into one data frame ``` import glob files = glob.glob("*.snappy.parquet") data = [pd.read_parquet(f,engine='fastparquet') for f in files] merged_data = pd.concat(data,ignore_index=True) ```
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
I ran into this question looking to see if pandas can natively read partitioned parquet datasets. I have to say that the current answer is unnecessarily verbose (making it difficult to parse). I also imagine that it's not particularly efficient to be constantly opening/closing file handles then scanning to the end of t...
This helped me to load all parquet files into one data frame ``` import glob files = glob.glob("*.snappy.parquet") data = [pd.read_parquet(f,engine='fastparquet') for f in files] merged_data = pd.concat(data,ignore_index=True) ```
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
This helped me to load all parquet files into one data frame ``` import glob files = glob.glob("*.snappy.parquet") data = [pd.read_parquet(f,engine='fastparquet') for f in files] merged_data = pd.concat(data,ignore_index=True) ```
a small change for those trying to read remote files, which helps to read it faster (direct read\_parquet for remote files was doing this much slower for me): ``` import io merged = [] # remote_reader = ... <- init some remote reader, for example AzureDLFileSystem() for f in files: with remote_reader.open(f, 'rb')...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
If you are going to copy the files over to your local machine and run your code you could do something like this. The code below assumes that you are running your code in the same directory as the parquet files. It also assumes the naming of files as your provided above: "order. ex: par\_file1,par\_file2,par\_file3 and...
You can use Dask to read in the multiple Parquet files and write them to a single CSV. Dask accepts an asterisk (\*) as wildcard / glob character to match related filenames. Make sure to set `single_file` to `True` and `index` to `False` when writing the CSV file. ```py import pandas as pd import numpy as np # crea...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
If you are going to copy the files over to your local machine and run your code you could do something like this. The code below assumes that you are running your code in the same directory as the parquet files. It also assumes the naming of files as your provided above: "order. ex: par\_file1,par\_file2,par\_file3 and...
a small change for those trying to read remote files, which helps to read it faster (direct read\_parquet for remote files was doing this much slower for me): ``` import io merged = [] # remote_reader = ... <- init some remote reader, for example AzureDLFileSystem() for f in files: with remote_reader.open(f, 'rb')...
51,696,655
I am new to python and I have a scenario where there are multiple parquet files with file names in order. ex: par\_file1,par\_file2,par\_file3 and so on upto 100 files in a folder. I need to read these parquet files starting from file1 in order and write it to a singe csv file. After writing contents of file1, file2 c...
2018/08/05
[ "https://Stackoverflow.com/questions/51696655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10183474/" ]
I ran into this question looking to see if pandas can natively read partitioned parquet datasets. I have to say that the current answer is unnecessarily verbose (making it difficult to parse). I also imagine that it's not particularly efficient to be constantly opening/closing file handles then scanning to the end of t...
If you are going to copy the files over to your local machine and run your code you could do something like this. The code below assumes that you are running your code in the same directory as the parquet files. It also assumes the naming of files as your provided above: "order. ex: par\_file1,par\_file2,par\_file3 and...
40,413,712
I downloaded wheel to the most recent version But I'm not entirely sure how to make of this semi-cryptic error message ``` Failed building wheel for mysql-python Command "/Users/username/Desktop/Project/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/bg/_nsyc_vxasdfx___h11f3j...
2016/11/04
[ "https://Stackoverflow.com/questions/40413712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4407093/" ]
As for me, it is because my system lack of python3 developing lib. It warns that there is no "Python.h" while installing. The following command fix it for me. `yum install python34-devel -y` `pip3 install mysqlclient`
The topic is quite old but for the people who might be suffered from having this problem,this can be your solution: First of all,you must open the file where you use Python like 3.5,3.6,Anaconda etc. Then open cmd in that file and run the command below: ``` $ pip install mysqlclient==1.3.12 ```
56,588,265
I've tried replacing each string but I can't get it to work. I can get all the data between `<span>...</span>` but I can't if is closed, how could I do it? I've tried replacing the text afterwards, but I am not able to do it. I am quite new to python. I have also tried using `for x in soup.find_all('/span', class_ = "...
2019/06/13
[ "https://Stackoverflow.com/questions/56588265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11644852/" ]
This problem is basically because the library you are using is in version 1.0.1 [mxgraph-js](https://www.npmjs.com/package/mxgraph-js), this library is very basic with the other features that the latest versions 4.0.6 [mxgraph](https://unpkg.com/[email protected]/javascript/mxClient.js) brings. In order for your prototype ...
I found a way to resolve this in my webpack project (vuejs) , maybe it's the same problem because all the mx Object must in window dict e.g. window['mxCell'] = mxCell so I write this ``` const {mxCell .......} = mxgraph({ mxImageBasePath: ..... }) // register all object window['mxClient'] = mxClient window['mxG...
40,764,894
I am trying to run Pylint and I am getting the below error: > > pkg\_resources.DistributionNotFound: The 'backports.functools-lru-cache' distribution was not found and is required by pylint > > > I found the below link, but not sure what to do with these files or where to place them. <https://pypi.python.org/simp...
2016/11/23
[ "https://Stackoverflow.com/questions/40764894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4663869/" ]
I had the same problem and I installed two missing dependencies (wrong configuration on the pylint or not updated pip??) Just do: ``` pip install backports.functools_lru_cache ``` then if you get an error like: ``` raise DistributionNotFound(req) ``` pkg\_resources.DistributionNotFound: configparser just do: ``...
I had this problem when running within a [virtual environment](https://virtualenv.pypa.io/en/stable/) on CentOS 7. On CentOS, the backports module is packaged as a yum package (`python-backports.x86_64`). The solution was to create the virtualenv using the [`--system-site-packages`](https://virtualenv.pypa.io/en/stab...
40,764,894
I am trying to run Pylint and I am getting the below error: > > pkg\_resources.DistributionNotFound: The 'backports.functools-lru-cache' distribution was not found and is required by pylint > > > I found the below link, but not sure what to do with these files or where to place them. <https://pypi.python.org/simp...
2016/11/23
[ "https://Stackoverflow.com/questions/40764894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4663869/" ]
From what I can tell certain versions of RHEL/CentOS have some sort of problem with the backports.ssl-match-hostname package in their yum repositories which can lead to problems when other backports packages get updated from PyPI. Specifically, in a RHEL7.2 environment I've reproduced the problem as follows: ``` > yum...
I had this problem when running within a [virtual environment](https://virtualenv.pypa.io/en/stable/) on CentOS 7. On CentOS, the backports module is packaged as a yum package (`python-backports.x86_64`). The solution was to create the virtualenv using the [`--system-site-packages`](https://virtualenv.pypa.io/en/stab...
13,358,283
I tried to start a smtp server with python with the following code: ``` import smtplib smtp_server = smtplib.SMTP('localhost') ``` And I get the following error: ``` File "test.py", line 2, in <module> smtp_server = smtplib.SMTP('localhost') File "/usr/local/lib/python2.7/smtplib.py", line 242, in __init__ ...
2012/11/13
[ "https://Stackoverflow.com/questions/13358283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/639165/" ]
`smtplib` is SMTP protocol client. What you are looking for is [`smtpd`](http://docs.python.org/2/library/smtpd.html).
The problem is that smtplib does not provide an SMTP server implementation, it implements SMTP client. Most likely, the code tries to connect to localhost and fails. See <http://docs.python.org/2/library/smtplib.html> Is the other machine you write about already running an SMTP server? And what are you trying to do?
42,762,924
To view the installed libraries on an environment I run this code within a Jupyter Python notebook cell : ``` %%bash pip freeze ``` This works, but how to conditionally execute this code ? This is my attempt : ``` from __future__ import print_function from ipywidgets import interact, interactive, fixed, interact...
2017/03/13
[ "https://Stackoverflow.com/questions/42762924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470184/" ]
You can just use the standard Python way: ``` import subprocess print(subprocess.check_output(['pip', 'freeze'])) ``` Then your function will work in any Python environment.
The short explanation is that the notebook has interactive commands which are handled by the notebook itself, before the Python interpreter even sees them. `%%bash` is an example of such a command; you cannot put this in Python code, because it's not Python. Using `bash` doesn't actually add anything here *per se;* us...
61,343,399
I want to ask about h3-py installation on windows I have tried to install h3 on windows with python I ran the command pip install h3 and it is installed. After install, when I try to import it, i get this error: ``` from h3 import h3 File "C:\Users\ASUS\AppData\Local\Programs\Python\Python36\lib\site-package...
2020/04/21
[ "https://Stackoverflow.com/questions/61343399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7765614/" ]
We're in the process of migrating the wrapper to Cython at <https://github.com/uber/h3-py/tree/cython> Would you mind trying to install this cython version with these (temporary) install steps: ``` pip install scikit-build pip install git+https://github.com/uber/h3-py.git@cython ``` Edit: We've released `3.6.1` al...
Apprently there was a problem with the package and after fixing it in the release v3.6.1 it works. they fixed install issues. As mentioned in this issue on github : <https://github.com/uber/h3-py/issues/32>
2,152,463
I get the following errors, I've placed [my name] for anonymity: ``` >>> python /Users/[myname]/Desktop/setuptools-0.6c11/ez_setup.py File "<stdin>", line 1 python /Users/[myname]/Desktop/setuptools-0.6c11/ez_setup.py ^ SyntaxError: invalid syntax ``` If you...
2010/01/28
[ "https://Stackoverflow.com/questions/2152463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/260666/" ]
The ez\_setup.py script may or may not work depending on your environment. If not, follow the instructions [here](http://pypi.python.org/pypi/setuptools). In particular, from the shell, make sure that the python 2.6 you installed is now invoked by the command `python`: ``` $ python Python 2.6.4 (r264:75821M, Oct 27 20...
Try running that command from a shell (i.e. straight from Terminal.app), not from inside the python interpreter.
69,460,583
I am deploying my project with heroku. My Django version number is 3.2.8 and python 3.9.7. It is written on heroku. Heroku supports Python 3.9.7 deployment, but there is an error in my push process. The version above does not support it. What should I do? Thank you for your reply This is my cmd ![enter image descriptio...
2021/10/06
[ "https://Stackoverflow.com/questions/69460583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17086297/" ]
I parsed the file you provided as an example [here](https://www.sec.gov/Archives/edgar/data/1087699/000108769999000001/0001087699-99-000001.txt). I first copied the data from the file to a txt file. The file `copied.txt` needs to be in the current working directory. This could give you an idea how to proceed. ```r lib...
You can use `httr` package to request the page: ``` > install.packages("httr") # follow instructions etc ``` Then in `R` shell (you might need a restart): ```r > httr::GET("https://www.sec.gov/Archives/edgar/data/1087699/000108769999000001/0001087699-99-000001.txt") ``` This will download the file successfully ho...
1,233,284
I want to hit a URL from python in google app engine. Can any one please tell me how can i hit the URL using python in google app engine.
2009/08/05
[ "https://Stackoverflow.com/questions/1233284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can use the [URLFetch API](http://code.google.com/appengine/docs/python/urlfetch/overview.html) ``` from google.appengine.api import urlfetch url = "http://www.google.com/" result = urlfetch.fetch(url) if result.status_code == 200: doSomethingWithResult(result.content) ```
It always depends on post or get. urllib can post to a form somewhere else, if we want the rather tricky thing validate between different hashes (sha and md5) ``` import urllib data = urllib.urlencode({"id" : str(d), "password" : self.request.POST['passwd'], "edit" : "edit"}) result = urlfetch.fetch(url="...
46,309,485
I have data that looks like this: ``` ['6005600401'] ['000000: PUSH1 0x05'] ['000002: PUSH1 0x04'] ['000004: ADD'] ``` The initial representation it's derived from is here: ``` 6005600401 000000: PUSH1 0x05 000002: PUSH1 0x04 000004: ADD ``` The output I'd like to create is like so: ``` PUSH1 0x60, PUSH1 0x40...
2017/09/19
[ "https://Stackoverflow.com/questions/46309485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3787253/" ]
Why not just split on ':'? ``` for line in status: data = line.split(:) if len(data) < 2: continue print(data[1].strip()) ```
This is one good way: ``` opcodes_list = list() for element in status.split('\n'): result = re.search(r"\b[A-Z].+", element) if result: opcodes_list.append(result.group(0)) ```
37,467,680
in the following code, there is indentation error at line 5. what i want is when if condition at line 4 is true then break should execute otherwise div=div+2 should execute. ``` max_num=input() for num in range(2,max_num+1): for div in range(3,max_num/2): if(num%div==0):break div=div+2 else: print num if(nu...
2016/05/26
[ "https://Stackoverflow.com/questions/37467680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5774499/" ]
Please use 2 or 4 spaces for indentation. I see your indentation is inconsistent - one time you use 1 space and the others you use 3. What you did **should** work as I see, but it's just inconsistent. Here is a slightly more organized version: ``` max_num=input() for num in range(2,max_num+1): for div in range(...
I suggest add this code, but i would want to know what is the wanted result for yor code. ``` max_num=input() for num in range(2,max_num+1): for div in range(3,max_num/2): if(num%div==0):break else:div=div+2 print num if(num==2): num=num+1 else : num=num+2 ```
48,254,890
I'm learning about how to import libraries from directories and I've stumbled upon an error I can't seem to figure out. I'm using the IMDBpy python library in a folder called lib. Below, I am importing the module which no longer returns any errors, but when I move to line number 6, I get the following error: ``` Trace...
2018/01/14
[ "https://Stackoverflow.com/questions/48254890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3808507/" ]
You can either write: ``` from lib.imdb import IMDb ia = IMDb() ``` or: ``` from lib import imdb ia = imdb.IMDb() ``` But importing `IMDb` and then calling `imdb.IMDb()` does not work. One other point to mention: If your *testlib.py* resides above the `lib` foder, then you need to add a `__init__.py` file with...
As mentioned above, it is different importing an object from importing a function. When you import a module such as `imdb` you may use its functions. However, when you import a function, you can only use that function, not the object/module where it came from. Check this for better examples: [Python 3 modules](https:/...