teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2020/02/16 12:20

投稿

hayataka2049
hayataka2049

スコア30939

answer CHANGED
@@ -1,8 +1,9 @@
1
1
  > You can refer to column names that contain spaces or operators by surrounding them in backticks. This way you can also escape names that start with a digit, or those that are a Python keyword. Basically when it is not valid Python identifier. See notes down for more details.
2
+ For example, if one of your columns is called `a a` and you want to sum it with `b`, your query should be `` `a a` + b ``.
2
3
  [pandas.DataFrame.query — pandas 1.0.1 documentation](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.query.html)
3
4
 
4
5
 
5
- **`**で囲うことで、こんな感じでエスケープできるはずです。
6
+ `` ` ``で囲うことで、こんな感じでエスケープできるはずです。
6
7
 
7
8
  ```python
8
9
  df.query("`売上(店舗)` == 0")

1

追記

2020/02/16 12:20

投稿

hayataka2049
hayataka2049

スコア30939

answer CHANGED
@@ -2,7 +2,7 @@
2
2
  [pandas.DataFrame.query — pandas 1.0.1 documentation](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.query.html)
3
3
 
4
4
 
5
- こんな感じでエスケープできるはずです。
5
+ **`**で囲うとで、こんな感じでエスケープできるはずです。
6
6
 
7
7
  ```python
8
8
  df.query("`売上(店舗)` == 0")