Is this sentence an imperative sentence, or does it have conditional meaning?
You hang around with riffraff like the Weasleys and that Hagrid, and it’ll rub off on you.
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It only takes a minute to sign up.Sign up to join this community
It's a complex situation.
Sentences like the presenting one are clearly intended to urge, if not impose, some kind of behavior on the addressee (though the addressee in this case is only a generic you, the same sense as one, but faluting a couple levels lower).
So in that they are like imperatives. However, it can be shown (as I do in my paper) that they aren't real imperatives, syntactically. They must be a different construction, mimicking an imperative. It's clear that the construction does have some conditional meaning --
which is the beginning of a Modus Ponens syllogism:
The second line is implied in context, and the conclusion follows.
An extreme case of this is
which means something like (boldfaced omissions)
[count noun]s, then you will save some money.
It could conceivably be read as an imperative (or, more correctly, an impositive as John Lawler explains in the comments):
[Go and] hang around with riffraff like the Weasleys and that Hagrid, and it’ll rub off on you.
But given the context, it's unlikely that the speaker meant it as a command. (After all - who would command someone to go get bad influences from riffraff?) It's more likely to be interpreted as a conditional:
[If] you hang around with riffraff like the Weasleys and that Hagrid,
andit’ll rub off on you.