output-formatting

Suppress descriptive output when printing pandas dataframe

本秂侑毒 提交于 2019-11-30 22:10:28
Say I have dataframe, c : a=np.random.random((6,2)) c=pd.DataFrame(a) c.columns=['A','B'] printing row 0 values: print c.loc[(0),:] results in: A 0.220170 B 0.261467 Name: 0, dtype: float64 I would like to suppress the Name: 0, dtype: float64 line so that I just get: A 0.220170 B 0.261467 Does anyone know how? (n.b. I am appending this to a text file) Andy Hayden You can tweak the __unicode__ method for a Series: In [11]: s = pd.Series([1, 2]) In [12]: s Out[12]: 0 1 1 2 dtype: int64 In [13]: pd.Series.__unicode__ = pd.Series.to_string In [14]: s # same with print Out[14]: 0 1 1 2 To append to

Suppress descriptive output when printing pandas dataframe

橙三吉。 提交于 2019-11-30 17:38:57
问题 Say I have dataframe, c : a=np.random.random((6,2)) c=pd.DataFrame(a) c.columns=['A','B'] printing row 0 values: print c.loc[(0),:] results in: A 0.220170 B 0.261467 Name: 0, dtype: float64 I would like to suppress the Name: 0, dtype: float64 line so that I just get: A 0.220170 B 0.261467 Does anyone know how? (n.b. I am appending this to a text file) 回答1: You can tweak the __unicode__ method for a Series: In [11]: s = pd.Series([1, 2]) In [12]: s Out[12]: 0 1 1 2 dtype: int64 In [13]: pd

Print a data frame with columns aligned (as displayed in R)

北城余情 提交于 2019-11-30 08:19:42
问题 I have the following data frame in R: > dframe Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 I want to print it into a file and keep it nicely formatted and aligned just as shown above. I use: write.table(dframe,file="test",sep="\t", quote=F) which produces the following output: Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 Since the data is displayed properly formatted within the R

How to show full column content in a Spark Dataframe?

旧巷老猫 提交于 2019-11-30 06:09:44
问题 I am using spark-csv to load data into a DataFrame. I want to do a simple query and display the content: val df = sqlContext.read.format("com.databricks.spark.csv").option("header", "true").load("my.csv") df.registerTempTable("tasks") results = sqlContext.sql("select col from tasks"); results.show() The col seems truncated: scala> results.show(); +--------------------+ | col| +--------------------+ |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...|

Format [pscustomobject] instances returned by Invoke-RestMethod or ConvertFrom-Json

一曲冷凌霜 提交于 2019-11-30 05:28:22
问题 I am trying to create a table from a JSON file I am receiving from a RESTful API. When I print the property of the json object I get an output like this: PS> Write-Output JSON.Object Object1 : @{key1=property; key2=property; key3=property; key4=property} Object2 : @{key1=property; key2=property; key3=property; key4=property} Object3 : @{key1=property; key2=property; key3=property; key4=property} Object4 : @{key1=property; key2=property; key3=property; key4=property} The output I would like to

How to control number of decimal digits in write.table() output?

混江龙づ霸主 提交于 2019-11-30 01:10:51
When working with data (e.g., in data.frame) the user can control displaying digits by using options(digits=3) and listing the data.frame like this. ttf.all When the user needs to paste the data in Excell like this write.table(ttf.all, 'clipboard', sep='\t',row.names=F) The digits parameter is ignored and numbers are not rounded. See nice output > ttf.all year V1.x.x V1.y.x ratio1 V1.x.y V1.y.y ratioR V1.x.x V1.y.x ratioAL V1.x.y V1.y.y ratioRL 1 2006 227 645 35.2 67 645 10.4 150 645 23.3 53 645 8.22 2 2007 639 1645 38.8 292 1645 17.8 384 1645 23.3 137 1645 8.33 3 2008 1531 3150 48.6 982 3150

Print a data frame with columns aligned (as displayed in R)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 06:43:47
I have the following data frame in R: > dframe Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 I want to print it into a file and keep it nicely formatted and aligned just as shown above. I use: write.table(dframe,file="test",sep="\t", quote=F) which produces the following output: Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 Since the data is displayed properly formatted within the R environment I thought it should be trivial to write it to a file with the same format. Apparently I was

How to format the output of kubectl describe to JSON

 ̄綄美尐妖づ 提交于 2019-11-29 05:31:01
kubectl get command has this flag -o to format the output. Is there a similar way to format the output of the kubectl describe command? For example: kubectl describe -o="jsonpath={...}" pods my-rc would print a JSON format for the list of pods in my-rc replication controller. But -o is not accepted for the describe command. janetkuo kubectl describe doesn't support -o or equivalent. It's meant to be human-readable rather than script-friendly. You can achieve what you described with kubectl get pods -l <selector_of_your_rc> -o <output_format> , for example: $ kubectl get pods -l app=guestbook

How to control number of decimal digits in write.table() output?

给你一囗甜甜゛ 提交于 2019-11-28 21:55:11
问题 When working with data (e.g., in data.frame) the user can control displaying digits by using options(digits=3) and listing the data.frame like this. ttf.all When the user needs to paste the data in Excell like this write.table(ttf.all, 'clipboard', sep='\t',row.names=F) The digits parameter is ignored and numbers are not rounded. See nice output > ttf.all year V1.x.x V1.y.x ratio1 V1.x.y V1.y.y ratioR V1.x.x V1.y.x ratioAL V1.x.y V1.y.y ratioRL 1 2006 227 645 35.2 67 645 10.4 150 645 23.3 53

How to show full column content in a Spark Dataframe?

℡╲_俬逩灬. 提交于 2019-11-28 15:20:05
I am using spark-csv to load data into a DataFrame. I want to do a simple query and display the content: val df = sqlContext.read.format("com.databricks.spark.csv").option("header", "true").load("my.csv") df.registerTempTable("tasks") results = sqlContext.sql("select col from tasks"); results.show() The col seems truncated: scala> results.show(); +--------------------+ | col| +--------------------+ |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07