我有一个简单的情节,x标签为1,1.25,1.5,1.75,2等,最多15:
该图是在pandas.DataFrame没有指定xtick间隔的情况下创建的:
speed.plot(kind='bar',figsize=(15, 7))
Run Code Online (Sandbox Code Playgroud)
现在我希望x-interval的增量为1而不是0.25,因此标签会显示为1,2,3,4,5等.
我确信这很容易,但我不能为我的生活弄清楚.
我发现plt.xticks()这似乎是正确的电话,但也许是set_xticks吗?
在此之前我没有按照我想要的方式更改了x刻度.任何帮助将不胜感激.
我正在尝试配置一台远程 linux 机器来访问我拥有的两个不同的 git 帐户。我不断获得身份验证访问权限。
> git push
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我采取的步骤,
key1和key2)~/.ssh/config 1 # Default github account: key1
2 Host github.com
3 HostName github.com
4 IdentityFile ~/.ssh/key1
5 IdentitiesOnly yes
6
7 # Other github account: key2
8 Host github-key2
9 HostName github.com
10 IdentityFile ~/.ssh/key2
11 IdentitiesOnly yes …Run Code Online (Sandbox Code Playgroud) 通常我使用 Pandas 来查看和处理数据,这是我所熟悉的。
如果我使用 psycopg2 模块从 postgres 数据库中提取数据,我会将 SQL 查询放在一个 python 文件中,但如果它是一个复杂的查询,它会在远离屏幕的一行上扩展。
有没有办法在python中使用换行符获取sql查询?即某种特殊字符包装器使python忽略空格?
这个
sql = SELECT devices.id, devices.names, devices.addresses, devices.charging, devices.covered, record_temperatures.time
FROM devices
WHERE devices.imei like '%0444258';
df = pd.read_sql_query(sql, con=conn)
Run Code Online (Sandbox Code Playgroud)
不是这个
sql = SELECT devices.id, devices.names, devices.addresses, devices.charging, devices.covered, record_temperatures.time FROM devices WHERE devices.imei like '%0444258';
df = pd.read_sql_query(sql, con=conn)
Run Code Online (Sandbox Code Playgroud) 我正在尝试删除现有表,执行查询,然后使用 pandas to_sql 函数重新创建表。这个查询在 pgadmin 中有效,但在这里不行。任何想法,如果这是一个熊猫错误或如果我的代码是错误的?
具体错误是ValueError: Table 'a' already exists.
import pandas.io.sql as psql
from sqlalchemy import create_engine
engine = create_engine(r'postgresql://user@localhost:port/dbname')
c = engine.connect()
conn = c.connection
sql = """
drop table a;
select * from some_table limit 1;
"""
df = psql.read_sql(sql, con=conn)
print df.head()
df.to_sql('a', engine)
conn.close()
Run Code Online (Sandbox Code Playgroud) 我正在尝试绘制每次有多个点的时间序列数据。我想time在 x 轴上,Amount在 y 轴上,然后按 ID 为每个点着色,即ID = 344它们都具有相同的颜色等。
下面是我正在使用的示例数据。我确定这一定存在,但我在 Matplotlib.org 上找不到图库示例
ID Amount
Time
2015-12-09 344 0.333333
2015-12-10 345 0.333333
2015-12-09 345 0.333333
2015-12-09 344 0.750000
2015-12-09 342 0.583333
Run Code Online (Sandbox Code Playgroud)
我尝试过的事情包括尝试将数据重塑为数据透视表(不起作用,因为ID 344.Groupby有两个重复值,但我一直在努力按两列分组,我想如果我可以分组 ID 并保留时间场这将有助于解决我的问题。
任何帮助或建议将不胜感激。
python ×4
pandas ×3
matplotlib ×2
git ×1
github ×1
plot ×1
postgresql ×1
psycopg2 ×1
sql ×1
sqlalchemy ×1
ssh ×1