MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / $getColumnData

Method $getColumnData

src/danfojs-base/core/frame.ts:94–137  ·  view source on GitHub ↗

* Returns the column data from the DataFrame by column name. * @param column column name to get the column data * @param returnSeries Whether to return the data in series format or not. Defaults to true

(column: string, returnSeries: boolean = true)

Source from the content-addressed store, hash-verified

92 * @param returnSeries Whether to return the data in series format or not. Defaults to true
93 */
94 private $getColumnData(column: string, returnSeries: boolean = true) {
95 const columnIndex = this.columns.indexOf(column)
96
97 if (columnIndex == -1) {
98 ErrorThrower.throwColumnNotFoundError(this)
99 }
100
101 const dtypes = [this.$dtypes[columnIndex]]
102 const index = [...this.$index]
103 const columns = [column]
104 const config = { ...this.$config }
105
106 if (this.$config.isLowMemoryMode) {
107 const data: ArrayType1D = []
108 for (let i = 0; i < this.values.length; i++) {
109 const row: any = this.values[i];
110 data.push(row[columnIndex])
111 }
112 if (returnSeries) {
113 return new Series(data, {
114 dtypes,
115 index,
116 columns,
117 config
118 })
119 } else {
120 return data
121 }
122
123 } else {
124 const data = this.$dataIncolumnFormat[columnIndex]
125 if (returnSeries) {
126 return new Series(data, {
127 dtypes,
128 index,
129 columns,
130 config
131 })
132 } else {
133 return data
134 }
135 }
136
137 }
138
139
140 /**

Callers 5

describeMethod · 0.95
sortValuesMethod · 0.95
setIndexMethod · 0.95
columnMethod · 0.95
getMethod · 0.80

Calls 1

indexOfMethod · 0.80

Tested by 1

describeMethod · 0.76