You should use &
/ |
operators and be careful about operator precedence (==
has lower precedence than bitwise AND
and OR
):
df1 = sqlContext.createDataFrame( [(1, "a", 2.0), (2, "b", 3.0), (3, "c", 3.0)], ("x1", "x2", "x3")) df2 = sqlContext.createDataFrame( [(1, "f", -1.0), (2, "b", 0.0)], ("x1", "x2", "x3")) df = df1.join(df2, (df1.x1 == df2.x1) & (df1.x2 == df2.x2)) df.show() ## +---+---+---+---+---+---+ ## | x1| x2| x3| x1| x2| x3| ## +---+---+---+---+---+---+ ## | 2| b|3.0| 2| b|0.0| ## +---+---+---+---+---+---+
Related Posts:
- How to change dataframe column names in pyspark?
- How to join on multiple columns in Pyspark?
- Spark RDD to DataFrame python
- How to change dataframe column names in pyspark?
- Pyspark: Exception: Java gateway process exited before sending the driver its port number
- environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON
- pandas: merge (join) two data frames on multiple columns
- How to delete columns in pyspark dataframe
- Pandas join issue: columns overlap but no suffix specified
- Converting Pandas dataframe into Spark dataframe error
- How to iterate over rows in a DataFrame in Pandas
- How to convert list to string [duplicate]
- How to uninstall a package installed with pip install –user
- numpy max vs amax vs maximum
- TypeError: ‘str’ object is not callable (Python)
- ModuleNotFoundError: No module named ‘sklearn’
- Does Python have an ordered set?
- Asking the user for input until they give a valid response
- Print a list in reverse order with range()?
- Configuring so that pip install can work from github
- Proper way to declare custom exceptions in modern Python?
- TypeError: ‘float’ object not iterable
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- Importing class from another file [duplicate]
- How to read a .xlsx file using the pandas Library in iPython?
- Numpy/Python Array Value error
- Changing the “tick frequency” on x or y axis in matplotlib?
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
- Remove all special characters, punctuation and spaces from string
- AttributeError: ” object has no attribute ”
- Plot pie chart and table of pandas dataframe
- ModuleNotFoundError: No module named ‘matplotlib’
- “inconsistent use of tabs and spaces in indentation”
- Pandas ‘count(distinct)’ equivalent
- How can I flush the output of the print function?
- Python calling method in class
- No module named pkg_resources
- Opening a .ipynb.txt File
- TypeError: list indices must be integers or slices, not str
- python object() takes no parameters error
- How do I find the distance between two points?
- How do I calculate percentiles with python/numpy?
- How do I remove a substring from the end of a string?
- Selecting with complex criteria from pandas.DataFrame
- How can I download Anaconda for python 3.6
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- Replace and overwrite instead of appending
- module ‘pandas’ has no attribute ‘rolling_mean’
- How to make a histogram from a list of data
- Using __add__ operator with multiple arguments in Python
- How to constantly run Python script in the background on Windows?
- Django – “no module named django.core.management”
- Type error Unhashable type:set
- Saving a Numpy array as an image
- RuntimeError: module compiled against API version a but this version of numpy is 9
- Python3 Error: TypeError: Can’t convert ‘bytes’ object to str implicitly
- How to run Pip commands from CMD
- Sorting and Grouping Nested Lists in Python
- Python Subprocess: Too Many Open Files
- urllib2.HTTPError: HTTP Error 403: Forbidden
- .write not working in Python
- Install Plotly in Anaconda
- ValueError: zero length field name in format in Python2.6.6
- Python NameError, variable ‘not defined’
- Cannot import cv2 in python in OSX
- convert csv file to list of dictionaries
- What’s the difference between “virtualenv” and “-m venv” in creating Virtual environments(Python)
- OperationalError: database is locked
- Decode Hex String in Python 3
- Python ImportError: No module named wx
- Accessing a class’ member variables in Python?
- Declaring a multi dimensional dictionary in python
- How do I compute derivative using Numpy?
- No module named utils error on compiling py file
- Convert Pandas Column to DateTime
- ImportError: cannot import name NUMPY_MKL
- Disable / Enable Button in TKinter
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- tkinter gui layout using frames and grid
- inverting image in Python with OpenCV
- Meaning of list[-1] in Python
- Tkinter error: Couldn’t recognize data in image file
- How to install Openpyxl with pip
- getting ZeroDivisionError: integer division or modulo by zero
- Iterating through list of list in Python
- Installing scipy for python 2.7
- Installing MySQL-python causes command ‘clang’ failed with exit status 1 on Mac OS 10.13.15
- Get difference between two lists
- How to install PyQt4 on Windows using pip?
- python dictionary error AttributeError: ‘list’ object has no attribute ‘keys’
- What is a mixin, and why are they useful?
- What is the most efficient way to store a list in the Django models?
- Convert list of dictionaries to a pandas DataFrame
- How to read html from a url in python 3
- Set variable in jinja
- Python how to write to a binary file?
- How to download a file via FTP with Python ftplib
- How do I restart a program based on user input?
- Python Pandas : pivot table with aggfunc = count unique distinct