Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to have framer read json timestamps

scala> val regex =  "([0-9-TZ.:]+) ({.*)"
regex: String = ([0-9-TZ.:]+) ({.*)

scala> val dff = df.withColumn("tstamp", regexp_extract('json_content, regex, 1)).withColumn("json", regexp_extract('json_content, regex, 2)).drop("json_content")
dff: org.apache.spark.sql.DataFrame = [country: string, city: string ... 2 more fields]

scala> dff.show(false)
+-------+-------+------------------------+----------------------------------+
|country|city   |tstamp                  |json                              |
+-------+-------+------------------------+----------------------------------+
|america|chicago|2019-06-28T00:00:00.000Z|{ "a": 123, "b": "456", "c": 789 }|
|india  |mumbai |2019-06-28T00:00:00.000Z|{ "a": 123, "b": "456", "c": 789 }|
+-------+-------+------------------------+----------------------------------+
Comment

PREVIOUS NEXT
Code Example
Python :: how to use drop for file in python 
Python :: jupyter notebook fancy print cross tab 
Python :: fill misssing values using sklrean 
Python :: get derivative of interp1d 
Python :: statistique in python 
Python :: can the function inside a function be global if the function before it is global 
Python :: how to subtract numbers in python 
Python :: Minimal requirements.txt django 
Python :: pandas use map lambda to fillna python 
Python :: opening & creating hdf5 file 
Python :: indentation error python 
Python :: how to change the jupyter navigator 
Python :: exercism Phone Number python 
Python :: cumulative some by date for each user 
Python :: response.url SSL warning python 
Python :: python indent selection 
Python :: python -m pip install --upgrade pip /usr/bin/python: No module named pip 
Python :: http online json 
Python :: user_info = user_info.save(commit=False) 
Python :: python make label display multiple lines 
Python :: what does - none do in python 
Python :: if condition python with index 
Python :: 2D array questions python 
Python :: add variable in text python 
Python :: how to apply class method to pandas python 
Python :: get method to create a set of counters in python 
Python :: funny application in python 
Python :: Django Signup urls.py 
Python :: flask buildspec.yml 
Python :: django auto complete light styling 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =