'Only allowed certain string in a column to be send to MySQL
I have a question. Am I able to allow only certain strings to be place into a DataFrame and then uploaded to MySQL?
For example, I want to only allow 'A' and 'B' onto MySQL with the column name of 'Channel'. I have an idea of doing it as followed:
if 'A' and 'B' not in df['Channel']:
pass
But it seems that there is still some strings which are not related would be send onto it. So is there any way to do this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
