PySpark:如何获得数据框中列的最大绝对值?

时间:2018-01-17 23:04:08

标签: pyspark pyspark-sql

假设我有

import * as firebase from 'firebase';

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

  user = {} as User

  async login(user: User){
    try{
      this.afAuth.auth.signInWithEmailAndPassword(user.email,user.password)
      .then(res => {
        //check if user has made profile if not send to profile setup page
        let user = firebase.auth().currentUser;
        if(user.emailVerified){ // note difference on this line
          console.log("Email is verified");
        }
     }catch(e){ 
       console.log(e);
     }
    }
  }

我想获得列+----+---+ | v1| v2| +----+---+ |-1.0| 0| | 0.0| 1| | 1.0| 2| |-2.0| 3| +----+---+ 的最大绝对值,即v1。谢谢!

1 个答案:

答案 0 :(得分:5)

aggmaxabs pyspark.sql.functions使用import pyspark.sql.functions as F df.agg(F.max(F.abs(df.v1))).first()[0] # 2

import React, {Component} from 'react'
import { Field, reduxForm } from 'redux-form'
import { connect } from 'react-redux'

import { toJS } from './to-js'

import FormFieldA from './FormFieldA'
import FormFieldB from './FormFieldB'

class MainSearchForm extends Component {

  render() {

    return(
    <form>
      <FormFieldA options={this.props.fieldAoptions}/>
      <FormFieldB options={this.props.fieldBoptions}/>
    </form>
    )
  }
}

function mapStateToProps ({Search}, props) {
  return {
    fieldAoptions: Search.get('fieldAoptions'),
    fieldBoptions: Search.get('fieldBoptions'),
  }
}

MainSearchForm = connect(mapStateToProps,{})(toJS(MainSearchForm));

export default reduxForm({
  form: 'main-search',
})(MainSearchForm)