Create more user friendly aliases from `col`
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
A issue identifica col(...) e .alias() como os pontos de entrada relevantes do Python, com o exemplo mostrando AVG(?table?.has_parking) como a saída indesejada. Comece localizando a implementação deles e quaisquer testes existentes; está concluído quando o ?table? padrão é removido, enquanto aliases explícitos como Area e Percentage of buildings with parking continuam funcionando.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
This is a user enhancement request to make the python interface remove the default ?table? on columns.
Describe the solution you'd like
I have not yet reviewed the applicable code to offer a best solution yet. I'm adding this feature request to track.
Describe alternatives you've considered
User adds an .alias() command as below, which may be tedious.
Additional context
See the below example from @datapythonista that includes the desired use case
import datafusion
from datafusion import col, lit, functions as f
import pyarrow
# something like this would be implemented internally, so users can call `datafusion.read_*`
def _read_parquet(*args, **kwargs):
ctx = datafusion.SessionContext()
return ctx.read_parquet(*args, **kwargs)
datafusion.read_parquet = _read_parquet # creating an alias of `read_*` functions so users don't need to know about `SessionContext` when the defaults are fine
df = (datafusion.read_parquet("buildings.parquet")
.filter( # `.filter()` accepting multiple conditions (which will be an AND) instead of having to use `&` with its operator precedence problems
col("is_offplan") == False,
col("rooms") >= 2, # `.lit(2)` not being required, and Python literals working with operators
)
.aggregate(
[col("area_name_en")],
[f.mean(col("has_parking").cast(float))], # `.cast()` accepting Python types, which would be internally converted to the PyArrow equivalent
)
.select(
col("area_name_en").alias("Area"),
col("AVG(has_parking)").alias("Percentage of buildings with parking"), # removing the default `?table?` in column names, the column name was "AVG(?table?.has_parking)"
)
)
- Linguagem predominante
- Python
- Estrelas
- 605
- Forks
- 176
- Merge médio
- 1d 23h
- PRs com merge (30d)
- 8
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/datafusion-python
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
apache/datafusion-python#1757 ·
-
documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/datafusion-python#1726 ·
-
Dificuldade 2/5 Meio dia Facilidade para iniciantes 88/100
apache/datafusion-python#1691 ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
apache/datafusion-python#1644 ·
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 30/100
apache/datafusion-python#1737 ·
Todas as issues de apache/datafusion-python
Issues semelhantes
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
canonical/paas-charm#368 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
tech debt
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
addition to tracking list Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
StevenBlack/hosts#3256 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
qualcomm/qai-appbuilder#275 ·