def rename_field(doctype, old_fieldname, new_fieldname):

	meta = frappe.get_meta(doctype, cached=False)
	new_field = meta.get_field(new_fieldname)
	if not new_field:
		print "rename_field: " + (new_fieldname) + " not found in " + doctype
		return

	if new_field.fieldtype == "Table":
		# change parentfield of table mentioned in options
		frappe.db.sql("""update `tab%s` set parentfield=%s
			where parentfield=%s""" % (new_field.options.split("\n")[0], "%s", "%s"),
			(new_fieldname, old_fieldname))
	elif new_field.fieldtype not in no_value_fields:
		if meta.issingle:
			frappe.db.sql("""update `tabSingles` set field=%s
				where doctype=%s and field=%s""",
				(new_fieldname, doctype, old_fieldname))
		else:
			# copy field value
			frappe.db.sql("""update `tab%s` set `%s`=`%s`""" % \
				(doctype, new_fieldname, old_fieldname))

		update_reports(doctype, old_fieldname, new_fieldname)
		update_users_report_view_settings(doctype, old_fieldname, new_fieldname)

	# update in property setter
	update_property_setters(doctype, old_fieldname, new_fieldname)
filter tag data.
dataset/ETHPy150Open frappe/frappe/frappe/model/utils/rename_field.py/rename_field--crossover with--dataset/ETHPy150Open CGATOxford/cgat/CGAT/Counts.py/filterTagDataPandas