python-3.x

Change grid size of a netCDF file

谁说我不能喝 提交于 2021-02-19 03:18:57
问题 Let's assume I have 2 netCDF data files with data for the same region (like South America, Africa, etc) but the different grid sizes as 0.5 degrees x 0.5 degrees and 1.0 degrees x 1.0 degrees in another. I want to increase or decrease its grid size to a different value such as 0.25 x 0.25 or 1.0 x 1.0 so that I can use this easily for raster calculations and comparison, etc. Is there a method to do this using any bash script, CDO, etc. A sample data can be downloaded from here. https://www

Change grid size of a netCDF file

。_饼干妹妹 提交于 2021-02-19 03:18:37
问题 Let's assume I have 2 netCDF data files with data for the same region (like South America, Africa, etc) but the different grid sizes as 0.5 degrees x 0.5 degrees and 1.0 degrees x 1.0 degrees in another. I want to increase or decrease its grid size to a different value such as 0.25 x 0.25 or 1.0 x 1.0 so that I can use this easily for raster calculations and comparison, etc. Is there a method to do this using any bash script, CDO, etc. A sample data can be downloaded from here. https://www

Python proxy authentication through Selenium chromedriver

青春壹個敷衍的年華 提交于 2021-02-19 03:10:18
问题 We tried for a few days to setup Proxy Authentication with selenium chromedriver in Python. We couldn't set ip up because Chrome throws a pop-up for authentication. Problem is that selenium can't switch to that window and so, can't type. The only solution that worked for us was using pyautogui which is a bad solution for us because we want to use the headless function. Here are all the methods we tried: driver.switch_to_window() driver.switch_to_active_element() driver.switch_to_alert()

Python proxy authentication through Selenium chromedriver

痞子三分冷 提交于 2021-02-19 03:06:10
问题 We tried for a few days to setup Proxy Authentication with selenium chromedriver in Python. We couldn't set ip up because Chrome throws a pop-up for authentication. Problem is that selenium can't switch to that window and so, can't type. The only solution that worked for us was using pyautogui which is a bad solution for us because we want to use the headless function. Here are all the methods we tried: driver.switch_to_window() driver.switch_to_active_element() driver.switch_to_alert()

Removing punctuation using spaCy; AttribueError

。_饼干妹妹 提交于 2021-02-19 03:00:24
问题 Currently I'm using the following code to lemmatize and calculate TF-IDF values for some text data using spaCy: lemma = [] for doc in nlp.pipe(df['col'].astype('unicode').values, batch_size=9844, n_threads=3): if doc.is_parsed: lemma.append([n.lemma_ for n in doc if not n.lemma_.is_punct | n.lemma_ != "-PRON-"]) else: lemma.append(None) df['lemma_col'] = lemma vect = sklearn.feature_extraction.text.TfidfVectorizer() lemmas = df['lemma_col'].apply(lambda x: ' '.join(x)) vect = sklearn.feature

Generate random Colors in Bar chart with Plotly Python

ぐ巨炮叔叔 提交于 2021-02-19 02:23:50
问题 I am using Plotly for Python to generate some stacked bar charts. Since I have 17 objects which are getting stacked, the colour of the bars has started repeating as seen in the image below. Can someone tell me how to get unique colours for each stack? Please find my code to generate the bar chart below: import plotly plotly.tools.set_credentials_file(username='xxxxxxxx', api_key='********') dd = [] import plotly.plotly as py import plotly.graph_objs as go import numpy as np for k,v in new

Generate random Colors in Bar chart with Plotly Python

妖精的绣舞 提交于 2021-02-19 02:23:47
问题 I am using Plotly for Python to generate some stacked bar charts. Since I have 17 objects which are getting stacked, the colour of the bars has started repeating as seen in the image below. Can someone tell me how to get unique colours for each stack? Please find my code to generate the bar chart below: import plotly plotly.tools.set_credentials_file(username='xxxxxxxx', api_key='********') dd = [] import plotly.plotly as py import plotly.graph_objs as go import numpy as np for k,v in new

Python3 function definition, arrow and colon [duplicate]

不羁岁月 提交于 2021-02-19 01:59:17
问题 This question already has answers here : What does -> mean in Python function definitions? (8 answers) Closed 2 years ago . I have found the following python function definition: def reverseString(self, s: 'List[str]') -> 'None': I don't quite understand 'List[str]' and -> 'None' . I have found that the arrow is a function annotation but I couldn't find anything useful and understandable for List[str]. Is it just an annotation? or does it enforce that the type of parameter s must be a string

PEP 424 __length_hint__() - Is there a way to do the same for generators or zips?

僤鯓⒐⒋嵵緔 提交于 2021-02-19 01:34:05
问题 Just came across this awesome __length_hint__() method for iterators from PEP 424 (https://www.python.org/dev/peps/pep-0424/). Wow! A way to get the iterator length without exhausting the iterator. My questions: Is there a simple explanation how does this magic work? I'm just curious. Are there limitations and cases where it wouldn't work? ("hint" just sounds a bit suspicious). Is there a way to get the hint for zips and generators as well? Or is it something fundamental only to iterators?

pandas extractall() is not extracting all cases given a regex?

牧云@^-^@ 提交于 2021-02-19 01:21:22
问题 I have a nested list of strings which I would like to extract them the date. The date format is: Two numbers (from 01 to 12 ) hyphen tree letters (a valid month) hyphen two numbers, for example: 08-Jan—07 or 03-Oct—01 I tried to use the following regex: r'\d{2}(—|-)(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2,4}' Then I tested it as follows: import pandas as pd df = pd.DataFrame({'blobs':['6-Feb- 1 4 Facebook’s virtual-reality division created a 3-EBÚ7 11 network of 500 free demo