axis

matplotlib axis label format

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am having an issue with the format of the tick labels of an axis. I disabled the offset from the y_axis: ax1.ticklabel_format(style = 'sci', useOffset=False) and tried to put it a scientific format but all I get is: 0.00355872 but I expected something like: 3.55872...E-2 or similar. what I really want is something like: 3.55872... (on the tick label) x 10^2 (or something similar - on the axis label) I could try to set the labels as static,, but in the end I will have a few tens or hundreds of plots with different values, so it needs to be

How to normalize an array in NumPy?

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to have the norm of one NumPy array. More specifically, I am looking for an equivalent version of this function def normalize(v): norm = np.linalg.norm(v) if norm == 0: return v return v / norm Is there something like that in skearn or numpy ? This function works in a situation where v is the 0 vector. 回答1: If you're using scikit-learn you can use sklearn.preprocessing.normalize : import numpy as np from sklearn.preprocessing import normalize x = np.random.rand(1000)*10 norm1 = x / np.linalg.norm(x) norm2 = normalize(x[:,np

Hiding axis text in matplotlib plots

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to plot a figure without tickmarks or numbers on either of the axes (I use axes in the traditional sense, not the matplotlib nomenclature!). An issue I have come across is where matplotlib adjusts the x(y)ticklabels by subtracting a value N, then adds N at the end of the axis. This may be vague, but the following simplified example highlights the issue, with '6.18' being the offending value of N: import matplotlib.pyplot as plt import random prefix = 6.18 rx = [prefix+(0.001*random.random()) for i in arange(100)] ry = [prefix+(0

Combine two columns of text in dataframe in pandas/python

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a 20 x 4000 dataframe in python using pandas. Two of these columns are named Year and quarter. I'd like to create a variable called period that makes Year = 2000 and quarter= q2 into 2000q2 Can anyone help with that? 回答1: dataframe["period"] = dataframe["Year"].map(str) + dataframe["quarter"] 回答2: df = pd.DataFrame({'Year': ['2014', '2015'], 'quarter': ['q1', 'q2']}) df['period'] = df[['Year', 'quarter']].apply(lambda x: ''.join(x), axis=1) Yields this dataframe Year quarter period 0 2014 q1 2014q1 1 2015 q2 2015q2 This method

java: Rpc/encoded wsdls are not supported in JAXWS 2.0

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using CXF 2.1 to generate java code from a wsdl, but I'm getting the following error: WSDLToJava Error: Rpc/encoded wsdls are not supported in JAXWS 2.0 org.apache.cxf.tools.common.ToolException: Rpc/encoded wsdls are not supported in JAXWS 2.0 at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.checkSupported(JAXWSDefinitionBuilder.java:141) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:87) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11

Renaming columns in pandas

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a DataFrame using pandas and column labels that I need to edit to replace the original column labels. I'd like to change the column names in a DataFrame A where the original column names are: [ '$a' , '$b' , '$c' , '$d' , '$e' ] to [ 'a' , 'b' , 'c' , 'd' , 'e' ]. I have the edited column names stored it in a list, but I don't know how to replace the column names. 回答1: Just assign it to the .columns attribute: >>> df = pd . DataFrame ({ '$a' :[ 1 , 2 ], '$b' : [ 10 , 20 ]}) >>> df . columns = [ 'a' , 'b' ] >>> df a b 0 1 10

In Python NumPy what is a dimension and axis?

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am coding with Pythons NumPy module. If coordinates of a point in 3D space are described as [1, 2, 1] , wouldn't that be three dimensions, three axis, a rank of three? Or if that is one dimension then shouldn't it be points (plural), not point? Here is the documentation: In Numpy dimensions are called axes. The number of axes is rank. For example, the coordinates of a point in 3D space [1, 2, 1] is an array of rank 1, because it has one axis. That axis has a length of 3. Source: http://wiki.scipy.org/Tentative_NumPy_Tutorial 回答1: In numpy

could not find deserializer for type : Error

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have to make a SOAP call from my java program ,for which I used apache axis. My program is as follows : import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.rpc.ParameterMode; import javax.xml.namespace.QName; public class Project { public static void main(String [] args) { try { String endpoint ="http://RequestUrl"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName(new QName(endpoint,

numpy.ma (masked) array mean method has inconsitent return type

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I noticed that the numpy masked-array mean method returns different types when it probably should not: import numpy as np A = np.ma.masked_equal([1,1,0], value=0) B = np.ma.masked_equal([1,1,1], value=0) # no masked values type(A.mean()) #numpy.float64 type(B.mean()) #numpy.ma.core.MaskedArray Other numpy.ma.core.MaskedArray methods seem to be consistent type( A.sum()) == type(B.sum()) # True type( A.prod()) == type(B.prod()) # True type( A.std()) == type(B.std()) # True type( A.mean()) == type(B.mean()) # False Can someone explain this?

Python Pandas - Re-ordering columns in a dataframe based on column name

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a dataframe with over 200 columns (don't ask why). The issue is as they were generated the order is ['Q1.3','Q6.1','Q1.2','Q1.1',......] I need to re-order the columns as follows: ['Q1.1','Q1.2','Q1.3',.....'Q6.1',......] Is there some way for me to do this within python? 回答1: df.reindex_axis(sorted(df.columns), axis=1) This assumes that sorting the column names will give the order you want. If your column names won't sort lexicographically (e.g., if you want column Q10.3 to appear after Q9.1), you'll need to sort differently, but